• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

I want to display default profile image if user do not have profile image

php


PHP Snippet 1:

if(!empty($path)){
  $path='<img src="/image/'.$image.'"/>';
} else {
  $path='<img src="/image/default.jpg"/>';
}

PHP Snippet 2:

<div>

  @if($user)
  <img src="{{ $user['user_avatar'] ? $user['user_avatar']:'default_profile_image' }}" alt="user image">

  @else
  <img src="default_profile_image" alt="user image">
  @endif

</div>

Related Snippets

Prevent blank space in pdf pages (DomPdf)

Vimeo API: how to save a vimeo into a subfolder?

PHP Include for HTML?

How can I pass the list to the component variable in Laravel?

PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll

Why isn't my PHP exception working?

woocommerce_wp_select options array from product attribute terms

PHP DOTENV unable to load env vars

How to execute sql code based on fetch array

PHP header location absolute URL

Form Validation and Submission to database

Undefined Array Key error when uploading image on php

Why is this PHP array not the same?

Laravel 8 Multiple Relationships for Factory

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

About Contact Privacy policy Terms and conditions