• 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

printing all running session variable in laravel 5.1

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

PHP Form Not Inserting

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

Fatal error: Trait 'LaminasDbAdapterLaminasDbAdapterAdapterInterface' not found in /var/www/vendor/laminas/laminas-db/src/Adapter/Adapter.php

Navigation idle on content download

html-php form submission after validation through JavaScript [closed]

In PHP, which is faster: preg_split or explode?

WooCommerce - unset "<product> removed notice…" on cart page

Best way to scrolldown onpageload

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

Add Metadata, headers (Expires, CacheControl) to a file uploaded to Amazon S3 using the Laravel 5.0 Storage facade

Multiple order by in WooCommerce

Jquery DataTables: Data not displaying in table via Ajax

Make Calculator - When Button clicked the No shows in Textbox.

About Contact Privacy policy Terms and conditions