• 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

Filter array by skipping every nth element from the end

php mysql + create a friend request system

WooCommerce Additional Information - if empty, hide

How to loop sql table data inside a html table

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

Yii2: How to download backup files using spanjeta/yii2-backup?

phpseclib 2.0 can not use Composer to create autoload

PHP Get value from JSON [duplicate]

Laravel Unknown Column 'updated_at'

Match single unknown parameter php (Morse-code Regex)

Match csv filenames to table names and import

PHP drop down list using array's and foreach (else and for) code

Fatal error: Trait 'LaminasDbAdapterLaminasDbAdapterAdapterInterface' not found in /var/www/vendor/laminas/laminas-db/src/Adapter/Adapter.php

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given [duplicate]

Correctly determine if date string is a valid date in that format

About Contact Privacy policy Terms and conditions