• 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 DOTENV unable to load env vars

Undefined variable in Laravel 8 project (php 7.4)

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given [duplicate]

Laravel multi auth - Authentication user provider [] is not defined

Cannot retrieve error message using Symfony HttpClient if the response is not "ok"

PHP each() function replacement

OAuth2 Token PHP

Laravel Delete and Update

What is the difference between client-side and server-side programming?

Testing subscription renewals on Stripe

How can I make Laravel return a custom error for a JSON REST API

How do I get friend list from Friends table with counts of friends of my friends

PHP password_verify

get data-value with variable value

Nginx RTMP not recording

About Contact Privacy policy Terms and conditions