• 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

Problems getting instance of UploadedFile in Yii2

Project structure for PHP

How to load Codeigniter 4 lang file into an array variable

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

ConstraintViolationListInterface to Exception in Symfony

Where do I need to place a hook for phpunit?

Nginx RTMP not recording

php: command not found Command PhaseScriptExecution failed with a nonzero exit code

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

How to run a shell as root from php (apache)

Laravel MSSQL Server Connection not working

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

How to loop sql table data inside a html table

About Contact Privacy policy Terms and conditions