• 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

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

HTML + PHP + PHPMAILER

Change user role if checkout custom checkbox is checked in WooCommerce

Multiply each value in array using array_map function

XML to CSV with PHP converter [problem with images grabing]

How to KeyBy where multiple items have the same key

Refresh specific HTML content that retrieves data from MySQL

Declaration of OMDb::query(string $statement) must be compatible with PDO::query

PHP if in_array() how to get the key as well?

Laravel Delete and Update

What is PHP's equivalent of JavaScript's "array.every()"?

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

XDebug not working in VScode for php debugging

Laravel: HTML in notification

Facebook PHP SDK - will not logout properly

About Contact Privacy policy Terms and conditions