• 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

Converting alphabet letter to alphabet position in PHP [duplicate]

PHP Deprecated issue when running artisan command

MySQL upgrade causing unexpected results on simple WHERE clauses

Convert every two values of an associative array into key-value pairs

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

Select option menu read from database and use it's values

Can I use a WooCommerce function without any WooCommerce page?

Laravel Get Days In Month From Month Number?

PHPSpreadsheet - How Do I Use Auto Migration Tool

How update php.ini on a Mac OS X Mojave?

Failing validation doesn't stop code execution in livewire component

I want a way to give path to my files which are outside of public folder in laravel

How to change the app environment at run time?

How to make dot match newline characters using regular expressions

How to pass security cloudflare server with php curl

About Contact Privacy policy Terms and conditions