Re: New years resolution: To get serious with my programming! Anyone wanna help? :)

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

 



Richard Lynch wrote:
> 
> On Tue, January 8, 2008 3:40 pm, Jack Mays wrote:
>>> funnily enough exit is even listed as a function.
>>>
>>>
>> Sure it is: http://us2.php.net/manual/en/function.exit.php
>>
>> Unless I'm missing a point here or something. :)
> 
> Technically, exit is "language construct" and not a function.
> 
> It does not require the () at the end.
> 
> There are more than a few "language constructs" that are documented
> just like functions because 99% of the time, nobody cares that they
> aren't functions.
> 
> Some common ones:
> 
> require
> include
> isset
> exit
> die ??? (maybe this one IS a function)
> echo
> print (used to be a function, maybe still is?)

Don't forget the infinitely useful "empty". It's particularly useful in
a loosely typed language but where your programming style is to check
everything twice before gingerly poking it with a long stick!

In reality it's usually a handy shortcut for checking e.g. array values.

You can replace:

if (isset($arr['idx']) && 0 != $arr['idx'])

with:

if (!empty($arr['idx']))

most of the time. (empty($var) returns true of $var is not defined, is
an empty string, a 0 numeric value, an empty array and maybe a few
others....

Col

-- 
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