• 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

Make Shipping Method fields Mandatory on Woocommerce checkout page

What is my SQL missing?

Laravel 5.2: Unable to locate factory with name [default]

How do I set the maximum php memory limit

Implode columnar values between two arrays into a flat array of concatenated strings

Combining a describing and one array with data

How to get variable from JavaScript to PHP [duplicate]

How can I make a full text index of the column?

carbon generated datetime not stored correctly into the database

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)

Assign output of PHP function to a variable

Correct way to use LIKE '%{$var}%' with prepared statements?

Ajax GET request fails in laravel 8

Make certain characters of a word from string bold

About Contact Privacy policy Terms and conditions