• 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 WooCommerce related products by Polylang language

Laravel whole batch is cancelled if one Job fails

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

Insert And Retrieve Data in MySQL with $.post Noob Question

Laravel unique validation on multiple columns

How to send upload image through email

Split comma separated value from table column into rows using mysql?

array_map triple dimensional array [duplicate]

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

Sagepay Error The Vendor failed to provide a RedirectionURL

Download & Save Zoom Recording in directory by PHP

Installing Composer - Internal Error

PHP usort() order in case of equality

PHP rotate matrix counter-clockwise

How to get Laravel's CSRF Token from Another Website?

About Contact Privacy policy Terms and conditions