• 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 convert time from one timezone to another in PHP

retrieve data from database using session

Handle error for duplicate entries - PHP/MySQL

php code to send checkbox form results to email

Add rows to Single product Additional information table in WooCommerce 3.6

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

PHP: remove filename from path

Add record for each array elements if missing in table

Laravel UUID generation

Laravel post contact form giving me error 419

Laravel database insert with combining array and string

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

Getting output of MS stored procedure on php call

Why rand() every time I refresh the page?

About Contact Privacy policy Terms and conditions