• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Programming / PHP Inline Conditional Reference

PHP Inline Conditional Reference

Last updated on April 16, 2020 by Sal Ferrarello

There are a number of different inline conditionals I use when working with PHP (i.e. ternary conditionals and the null coalescing operator). As a reminder of how some of these common inline conditionals work, I put together this table for reference.

$value $value ? $value : 13
$value ?: 13
isset( $value ) ? $value : 13
$value ?? 13
! empty( $value ) ? $value : 13
0 (zero) 13 0 13
false 13 false 13
unassigned 13
throws “undefined variable” notice
13 13
null 13 13 13
'sal' 'sal' 'sal' 'sal'
'' 13 '' 13
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Dev Tips, Draft, Programming Tagged With: PHP

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in