• 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

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

XDebug not working in VScode for php debugging

Dynamic dropdown Ajax PHP request

How to display MySQL table using php and edit it in a web browser

How to change HTML structure inside WP <head>

Zig-zag scan an N x N array

Magento 2 - How to add new block to admin panel in product page?

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

shell errors running php exec

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

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

Error Class "LaravelFortifyFeatures" not found

Nginx RTMP not recording

Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path: ) in Unknown on line 0

woocommerce get_order_report_data to show order_item_id

About Contact Privacy policy Terms and conditions