• 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

How can I easily switch between PHP versions on Mac OSX?

Check if a string contain multiple specific words

Get image type from base64 encoded src string

How to display table header in every page using FPDF library?

Google Gmail API - How to login programatically?

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

How to get company posts from LinkedIn via API?

Laravel after login Two factor not working

Laravel: HTML in notification

get data-value with variable value

How to override header set in Apache config with more specific header in a virtual host

wordpress : How to specify the cause "This site can’t be reached"

Return new collection without modifying original collection

PHP Slim Framework request using withAttribute error

OAuth2 Token PHP

About Contact Privacy policy Terms and conditions