• 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

Failing validation doesn't stop code execution in livewire component

Handle error for duplicate entries - PHP/MySQL

PHP drop down list using array's and foreach (else and for) code

How do I loop through an MS SQL database with VB.NET?

Transfer data between JavaScript and PHP through JSON

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

PHP contact form configuration [duplicate]

how can I set a session variable in Drupal 8 and get it in a php script?

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

OAuth2 Token PHP

Error when uploading certain .png files "Interlace handling should be turned on when using png_read_image"

SQLSTATE[HY000]: General error: 1 table posts has no column named *

Unable to create lockable file - Laravel 8 & PHP 8

Laravel 5: Is there a non-case sensitive way to sort a collection by an attribute?

How to increase the PHP upload limits [duplicate]

About Contact Privacy policy Terms and conditions