Skip to content

Instantly share code, notes, and snippets.

@olavocneto
Created November 10, 2012 01:47
Show Gist options
  • Save olavocneto/4049447 to your computer and use it in GitHub Desktop.
Save olavocneto/4049447 to your computer and use it in GitHub Desktop.
In expression (expr1) ? (expr2) : (expr3), if not set expre2 and expr1 is true then print 1 when echo usage.
<?php
$var = "string";
echo isset($var) ? : 'ooh'; // 1
//echo isset($var) ? : ; // Parse error: syntax error, unexpected ';'
var_dump(isset($var) ? : 'ooh'); // boolean true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment