• 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 - add comma thousands separator but remove trailing zeros

How can I get new CSRF token in LARAVEL by using ajax

PHP SoapClient: set a namespace without prefix

WooCommerce - unset "<product> removed notice…" on cart page

How to trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?

Add Class in html Dynamically in PHP

How to Display Data in Yajra Datatables Laravel 7?

retrieve data from database using session

Parsing JSON File to array in PHP

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

500 (Internal Server Error) with Laravel & Docker [duplicate]

WordPress - Dynamically add user ID to the end of a URL

advanced custom fields wordpress custom class

How to modify CSS in a specific page of the WP admin dashboard (backend)

Getting output of MS stored procedure on php call

About Contact Privacy policy Terms and conditions