using && and/or || to replace if
Posted: Fri Jul 06, 2007 5:41 pm
Hi all.
I was looking through some js code one day when I noticed that it did something like this:
meaning,
I know it works because of short circuiting, but I was wondering if you could do this in php.
So,would something like this work?
or
I was looking through some js code one day when I noticed that it did something like this:
Code: Select all
a=a||documentCode: Select all
if(a){
a=a;
}else{
a=document;
}So,would something like this work?
Code: Select all
$var=$_POST['var1'] || 'default string';Code: Select all
$var=isset($_POST['var1']) && $_POST['var1'];