• 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 echo remove slashes from url [duplicate]

Attempted to call an undefined method named "get" of class "MailController"

Call to a member function givePermissionTo() on null

Testing subscription renewals on Stripe

Laravel no logout option from menu after successfull login

PHP: How to quickly split a key=value file into associative array

Reorder attribute dropdown terms in Woocommerce single variable products

PHPExcel_IOFactory::createWriter causes wrong behaviour

PHP: remove filename from path

Changing font color in javascript

Generate random username based on full name php

Which is faster php date functions or carbon?

PHP SoapClient: set a namespace without prefix

How can I convert from a{a{} b{}} to a[a[],b[]] using php preg_match?

Convert PHP array into HTML tag attributes separated by spaces

About Contact Privacy policy Terms and conditions