Greetings, Good Man.
In reply to Your message dated Thursday, October 25, 2007, 01:36:44,
>>I am new to php and google doesn't allow for searching on the @
symbol.
I have a script with the following line:
if (@$type_toggle || @cat_toggle) {
do_query..... ...
What does the @ do? Can you give me a link so I can read about it.
it surpresses error messages, so that if the variable "$type_togg le"
or "$cat_toggl e" doesn't exist, error messages/warnings will not be
printed to the screen.
GMand by the way, in relation to the "register_globa ls" questions that have
GMgone around the last couple of days, the script above is a perfect example
GMof why register_global s should be turned off.
GMif register_global s is on, simply checking for a variable will ALWAYS
GMreturn true, so in the code above, $type_toggle and $cat_toggle BOTH exist
GMand the query will ALWAYS be performed.
Then, to avoid ambiguous comparison, use clarifying functions.
In the example showed above:
if(!empty(@$typ e_toggle) || !empty(@cat_tog gle))
{
do_query....... .
To make sure You have non-empty array $arr:
if(is_array($ar r) && count($arr))
{
do_something();
}
Notice: it is not enough to check for count($var) as far as ordinary variables
always return 1 == count($var), so, construction:
if(count($var))
{
foreach($var as ...)
Will end in "Supplied variable should be an array" in some cases.
--
Sincerely Yours, AnrDaemon <an*******@free mail.ru>