• 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

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

php code to send checkbox form results to email

Modify microseconds of a PHP DateTime object

cakephp save drag and drop list order to database

Eloquent insert id with sequence next value

Navigation idle on content download

Cannot connect to own websocket server when on secured domain

image source not readable

Getting values for an enum?

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

I'm trying to write a clean url for my website using the $_SERVER['REQUEST_URI'] in php

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

PHP array, move keys and values to new array, but mix it up

Laravel websockets AWS EC2 - Connection failed

Coinpayments create_transaction "ERROR: Invalid command!"

About Contact Privacy policy Terms and conditions