• 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

How to create a video stream from a single dynamic image in PHP

Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs

Laravel post contact form giving me error 419

generate an Excel file using PHP

PHPUnit (Phar) Fatal Error Only When Test Fails

Find out the name of the last script that included the current one

Access denied for user 'homestead'@'localhost' (using password: YES)

Class AppHttpControllersUserController Does Not Exist

How to delete old images from public folder on update using Laravel

Printing more than one array using print_r or any other function in php

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

PHP array sort and remove duplicates by two field values

woocommerce_wp_select options array from product attribute terms

What is the difference between client-side and server-side programming?

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

About Contact Privacy policy Terms and conditions