• 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

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

Correct way to use LIKE '%{$var}%' with prepared statements?

PHP code for generating decent-looking coupon codes (mix of letters and numbers)

Why does array_map() with null as callback create an "array of arrays"?

Don't show recurring price for WooCommerce subscriptions worth 0$

HTTP Range requests with php for Video Embedding for solving going to specific time in video (seek bar not work)

MySQL upgrade causing unexpected results on simple WHERE clauses

Lumen - Postgresql setup - Composer

Require a class from another class - php

ldap is missing from system when installing adldap2 in laravel

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

Timber: Single post pagination does not work (wp_link_pages)

Detect emoticons in string

Get WooCommerce products from specific category

add_action() function in wordpress not working [duplicate]

About Contact Privacy policy Terms and conditions