• 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

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given [duplicate]

How to show selected value using javascript in laravel

WHERE IN array binding in DB::raw laravel 5.4

generate an Excel file using PHP

how to prevent float variables displaying as scientific notation when printing [duplicate]

PHP/HTML: Creating A SubMenu

dompdf and img tag, image wont show

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

PHP mail sending empty mails

Laravel - How to properly generate unique slugs from article titles?

Nginx disallowing execution of PHP in uploads directory with Magento

Filter array by skipping every nth element from the end

Laravel SQL query midnight time not showing

How to implement placeholder in a php file for moodle plugin?

The difference when using if statement true === something() vs something() === true [duplicate]

About Contact Privacy policy Terms and conditions