• 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

carbon generated datetime not stored correctly into the database

Explain how this array transposing and flattening function works

PHP/HTML: Creating A SubMenu

PHP - installing Xdebug on Mac with XAMPP (Unix File)

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

PHP Get value from JSON [duplicate]

Parameter is not sent to Laravel route in Ajax

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

PHP: Telegram Bot: Insert line break to text message

Symfony/Form add attribute based on the data

api response laravel doesn't show

How can I create a Download Page with post php method?

How to insert Google Adsense Code in PHP script?

Distribute array row data to make multiple new rows

Unable to create lockable file - Laravel 8 & PHP 8

About Contact Privacy policy Terms and conditions