• 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

insert multiple rows in a saveall in cakephp

PHPUnit (Phar) Fatal Error Only When Test Fails

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

woocommerce get_order_report_data to show order_item_id

Insert multidimensional array to codeigniter cart

generate an Excel file using PHP

Uploading video to Youtube using Youtube Data API V3 and Google API Client PHP -- getting 401 (unauthorized) message

How to downgrade or install a specific version of Composer?

How to send parameters in soap request in php in __soapcall() function

Add restriction to WooCommerce coupons by allowed user ID

Center point of multiple gps coordinates with php

Best way to scrolldown onpageload

Artisan, creating tables in database

How do I get friend list from Friends table with counts of friends of my friends

Chunk and transpose a flat array into rows with a specific number of columns

About Contact Privacy policy Terms and conditions