• 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 : How to Create Dropdown to Select FOREIGN KEY from Other Table?

Distribute array row data to make multiple new rows

Server-sent events in PHP (without echo or print)

How to keep value of selected value after form submission?

Live search query using JS and PHP for QA forum

Laravel query builder binding parameters more than once

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

Use Python plotly chart in PHP

Laravel Factory not calling callback 'afterCreating'

Why isn't my PHP exception working?

Do I need to install `fxp/composer-asset-plugin` if I'm not doing front-end development

PHP function Not Working As Expected From functions.php Include File

Laravel-fopen: failed to open stream: Permission denied

Laravel MSSQL Server Connection not working

PHP each() function replacement

About Contact Privacy policy Terms and conditions