• 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

Query Optimization, changing the queries in the loop into a single processing query

Check if user online laravel

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

Convert PHP array into HTML tag attributes separated by spaces

Custom API and cunsuming in php?

Substitute integers and dots with regex [duplicate]

Distribute array row data to make multiple new rows

Get number of working days between two dates in PHP [duplicate]

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

PHP: convert all UTF-8 characters to HTML entities

Confirm Leave on External Links in Wordpress

PHP block shortcut in Visual Studio Code

how to retrieve the first and last instance of a row in pdo dataset

Symfony autowiring issues since docker update

Lexik JWT authentication problem "Invalid credentials"

About Contact Privacy policy Terms and conditions