Function TRUE/FALSE return valuesPodręcznik PHPPoprzedniDodatek D. Migrating from PHP/FI 2 to PHP 3NastępnyFunction 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.
Przykład D-8. 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;
]]|
</programlisting>
</example>
<example>
<title>Migration from 2.0: return values, new code</title>
<programlisting role="php">
<![CDATA[
$fp = @fopen($file, "r") or print("Could not open $file for reading<br>\n");
PoprzedniSpis treściNastępnyShort-circuited boolean evaluationPoczątek rozdziałuOther incompatibilities
Wyszukiwarka
Podobne podstrony:
migration truefalsemigration truefalsemigration4 parsermigration boolevalmigration startendtagsmigration if endifmigration4 missingmigrationmigration4 extensionstruefalsemigration4migrating globustruefalsewięcej podobnych podstron