• 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

LARAVEL: How to fetch id dynamically in a query builder?

How to programmatically find public properties of a class from inside one of it's methods

"There is no active transaction" when refreshing database in Laravel 8.0 test

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

Reorder attribute dropdown terms in Woocommerce single variable products

Insert multidimensional array to codeigniter cart

Best way to scrolldown onpageload

php code to send checkbox form results to email

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

Show date difference as "20" instead of "20 years ago"

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

file_get_contents() without "Http" to access external URL [closed]

How to trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

PHP date() with timezone?

About Contact Privacy policy Terms and conditions