• 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

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

PHP 8 - libxml_disable_entity_loader() has been deprecated. How do I replace the functionality it provides?

Login if user is active using Laravel Breeze

Prestashop cUrl Login

PHPUnit (Phar) Fatal Error Only When Test Fails

CodeIgniter extend CI_URI undefined method

how to get the header value, if we don't know the value because the value is random from the server

PHP Find Array Index value in multi-line array

How to add a heading in between checkout fields of WooCommerce

add_action() function in wordpress not working [duplicate]

Laravel - Implicit route model binding with soft deleted data

how to redirect the user back to desired URL after login page in PHP?

How to convert time from one timezone to another in PHP

Composer Warning: openssl extension is missing. How to enable in WAMP

how to fix Service provider class not found when using repository?

About Contact Privacy policy Terms and conditions