• 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

Using if(isset($_POST['submit'])) to not display echo when script is open is not working

Telegram bot doesn't answer

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

Multiple order by in WooCommerce

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

Adding multiple items to WooCommerce cart at once

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

Inserting Country Selection into MySQL PHP [duplicate]

Display the WooCommerce product price inside a custom function

Sum array values of a column within each column of an array with 3 levels

how to pass row id in href of a tag in codeigniter controller?

Increase value by 1 on button click

printing all running session variable in laravel 5.1

Warning: sqlite_query() expects parameter 1 to be resource, string given

PHP random string generator

About Contact Privacy policy Terms and conditions