• 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 loop sql table data inside a html table

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

Cannot pass null argument when using type hinting

Adding the custom page with add_menu_page function on Wordpress

Undefined Array Key error when uploading image on php

RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)

Convert regular text to array using notepad++

How to get monthly wise data in laravel

Can we define variables in `.tpl` files?

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

best way to store error messages in Laravel (session or variable)

I want to display a sweetalert after the inserting of data in my database

PHP Fatal error: Class not found - PHPUnit

Hide email address with stars (*)

How to get company posts from LinkedIn via API?

About Contact Privacy policy Terms and conditions