Skip to content

Instantly share code, notes, and snippets.

@Jan-Bart
Created June 10, 2014 13:39
Show Gist options
  • Save Jan-Bart/cfd0f59a4380adbb2b8e to your computer and use it in GitHub Desktop.
Save Jan-Bart/cfd0f59a4380adbb2b8e to your computer and use it in GitHub Desktop.
Test to see if we can use fn = fn || new Function(); in PHP as well
<?php
echo "Test var1 en var2 = 'iets'";
$var1 = "";
$var2 = "iets";
$temp = $var1 || $var2;
echo " Result: ". $temp. "\n";
var_dump($temp);
echo "Test var1 = 'iets' en var2 = ''";
$var1 = "iets";
$var2 = "";
$temp = $var1 || $var2;
echo " Result: ". $temp. "\n";
var_dump($temp);
echo "Test var1 = '' en var2 = ''";
$var1 = "";
$var2 = "";
$temp = $var1 || $var2;
echo " Result: ". "\n";
var_dump($temp);
// OUTPUT:
// Test var1 en var2 = 'iets' Result: 1
// bool(true)
// Test var1 = 'iets' en var2 = '' Result: 1
// bool(true)
// Test var1 = '' en var2 = '' Result:
// bool(false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment