[UPHPU] short syntax without the else?

Scott Hill llihttocs at gmail.com
Sun Jan 20 19:16:31 MST 2008


>
> Keep in mind that this is a bit more difficult read than the standard:
>
> if($condition == false && $var == "foo")
> {
>        echo false
> }
> else
> {
>        echo "foo";
> }
>
> especially if you've got multiple people working on the same code.
>
>
I agree with this.  The expression $x = $y==1; is valid but it's hard to
read.  In order for our code to have any kind of legacy, it might be best to
type a few more characters and use
$x = false;
if ($y == 1)
    $x = true;

or whatever else we can type to help others after us figure out what we
meant to do (or at least get close);

My humble $.02

-- 
Scott Hill

Food for thought:
An eagle may soar but a weasel will never get sucked into a jet engine.
A closed mouth gathers no foot.
Never squat with your spurs on.


More information about the UPHPU mailing list