Skip to content

Instantly share code, notes, and snippets.

@tassoevan
Created September 11, 2014 18:46
Show Gist options
  • Save tassoevan/4e89bee324623f4c4366 to your computer and use it in GitHub Desktop.
Save tassoevan/4e89bee324623f4c4366 to your computer and use it in GitHub Desktop.
Tests on shorthand ternary operator in PHP
<?php
function first()
{
echo "#1\n";
return false;
}
function second()
{
echo "#2\n";
return false;
}
function third()
{
echo "#3\n";
return false;
}
function forth()
{
echo "#4\n";
return false;
}
first() ?: second() ?: third() ?: forth();
// $ php teste.php
// #1
// #2
// #3
// #4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment