• 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

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

Laravel Database Strict Mode

backup files to google drive using PHP

php - add comma thousands separator but remove trailing zeros

How to make a array inside array?

Mysqli multi query error

Laravel Pagination links() not working

I need to link Google Sheet with my Laravel

CodeIgniter extend CI_URI undefined method

WordPress Subquery returns more than 1 row on SELECT

PHP each() function replacement

PHP rotate matrix counter-clockwise

Spam Filter in Contact Form

Laravel get user data with profile

how to see if database exists with PDO [duplicate]

About Contact Privacy policy Terms and conditions