• 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

Show date difference as "20" instead of "20 years ago"

Valet, Xdebug after reboot Big Sur not working

Add New Parameter to Existing URL using htaccess

How do I remove this delivery notification from here?

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

How to get the total hour from starting time to end time in php

PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll

PHP: Telegram Bot: Insert line break to text message

Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type

Display specific shipping method if woocommerce product has specific acf field value

sort() not affecting original array while inside foreach loop

Transfer data between JavaScript and PHP through JSON

Post Form Data To phpmyadmin Database

PHP mail function is sending blank message body

Wordpress how to get the post thumbnail inside a figure tag

About Contact Privacy policy Terms and conditions