Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

Function TRUE/FALSE return values

Most internal functions have been rewritten so they return TRUE when successful and FALSE when failing, as opposed to 0 and -1 in PHP/FI 2.0, respectively. The new behaviour allows for more logical code, like $fp = fopen("/your/file") or fail("darn!");. Because PHP/FI 2.0 had no clear rules for what functions should return when they failed, most such scripts will probably have to be checked manually after using the 2.0 to 3.0 convertor.

Пример D-9. Migration from 2.0: return values, old code

$fp = fopen($file, "r");
if ($fp == -1);
    echo("Could not open $file for reading<br />\n");
endif;

Пример D-10. Migration from 2.0: return values, new code

$fp = @fopen($file, "r") or print("Could not open $file for reading<br />\n");



add a note add a note User Contributed Notes
Function TRUE/FALSE return values
oliver at hankeln-online dot de
07-Aug-2002 08:22
I guess you are indeed wrong. You are right, 'FALSE' is beeing evaluated as a string. But it is compared with a number, so automatic type conversion takes place. 'FALSE' as well as 'FOO' and so on are converted to 0. And (0==0) is obviously true. So the number does matter. Try an other number...

Oliver
wildpeaks at warpdawg dot com
06-Aug-2002 07:30
'FALSE' is interpreted as a string containing the word false and not as a boolean value, and comparing a non-null string to a number, whatever the number is, returns true (i may be wrong).
dtampe at groupadress dot com
25-Oct-2001 10:27
Try this:

if(0=='FALSE')
      echo "It works but it should not work";

1 days of headheache...

Hope it helps!
DamTam

 
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571