Re: navigation include not functioning (RESOLVED)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes, that's a golden rule for a bug free code.
The rule shoudl be something like this...

Whenever you have a constant value evaluated to a non-constant value
put them in the left side of the expression.

if( 'constant' == $non_constant )
    echo ' variables has that name for anything ';

if( false !== ( $pos = strpos( 'php', 'I love php sintax' )))
    echo ' we all love it ';

Also note that is easy to count the closing parenthesis
(if your editor does not helps try with SciTE)

On Wed, Aug 5, 2009 at 6:55 PM, Ben Dunlap<bdunlap@xxxxxxxxxxxxxxxxxx> wrote:
>> In my navigation.php include file, I had if ($page = about) echo href....
>> I changed it to if ($page == about) echo.... and it suddenly worked! Imagine
>> that...
>
> Another good case for putting the variable on the right side of "==":
>
>   if ("about" == $page)
>
> Then if you mis-type "==" as "=", PHP will fail immediately with a parse error.
>
> It feels a little weird but if it saves a lot of head-desk moments it's
> probably worth it. Now if only I could get into the habit myself...
>
> Ben
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Martin Scotta

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux