• 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

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

google content api for shopping

How can I format this number correctly using PHP?

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

how to see if database exists with PDO [duplicate]

Mobile browsers are adding .html to filename on download

(Laravel) How to delete multiple models including optional relationships?

Extract string between first whitespace and last whitespace in php

zsh: command not found: php

Jquery DataTables: Data not displaying in table via Ajax

PHP array slice from position + attempt to return fixed number of items

PHPSpreadsheet - How Do I Use Auto Migration Tool

Getting values for an enum?

Eloquent insert id with sequence next value

Laravel: Create morphs() relationship nullable

About Contact Privacy policy Terms and conditions