• 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

Laravel UUID generation

How to reset Laravel AuthManager/guards in between API calls in tests?

Target Individual Form Instance/Counter Inside A PHP While Loop

php 7 php.ini upload_max_filesize not working

Laravel - Browser displays message again when I press back button

How to display table header in every page using FPDF library?

Nginx disallowing execution of PHP in uploads directory with Magento

How to Display Data in Yajra Datatables Laravel 7?

PHP and WebView - Cookie doesn't are the same

PhpSpreadSheet: How to save Workbook sheets in individual CSV files

AJAX call fails with SyntaxError: Unexpected end of JSON input

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

PHP Warning: Module already loaded in Unknown on line 0

how to see if database exists with PDO [duplicate]

Add customer email and phone in "Order" column to admin orders list on Woocommerce

About Contact Privacy policy Terms and conditions