• 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

PHP -> Next nearest date defined by array of days in week

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

WHERE IN array binding in DB::raw laravel 5.4

How to test a php login connected to a mysql db through xampp?

how to loop through json response data using ajax jquery?

Install mysql client in docker image

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

php echo remove slashes from url [duplicate]

Saving Data from form to database using AngularJS and php

How to fix Call to undefined method AppModelsTableName::factory?

Dropdown with current value from Mysql

Load a .env file with PHP

Laravel views are showing from cache on one server but works fine on other server

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

Backend cannot be reached after Typo3 login screen

About Contact Privacy policy Terms and conditions