• 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

Yii Ajax Submit button

PHP block shortcut in Visual Studio Code

Using array_intersect on a multi-dimensional array

PHP each() function replacement

MongoDB Duplicate Documents even after adding unique key

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

Problems getting instance of UploadedFile in Yii2

How to access a var with "-" in PHP [duplicate]

Manage independently the decimal number of the price of each product [duplicate]

Chunk and transpose a flat array into rows with a specific number of columns

mysql slow on updates for a well optimized query

php script to delete files older than 24 hrs, deletes all files

Wordpress 'post_type_link' hides permalink

Pagekite error: FAIL: localhost:8080 is down

protect my blog content

About Contact Privacy policy Terms and conditions