#47307 [Opn->Bgs]: Very wrong info in documentation
ID: 47307
Updated by: preinheimer@php.net
Reported By: saskia at sa5kia dot nl
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
Operating System: NetBSD
PHP Version: Irrelevant
New Comment:
The function does indeed return boolean values:
<?php
var_dump(file_exists(__FILE__));
var_dump(file_exists('something_else_doesnt_exist'));
yeilds:
bool(true)
bool(false)
PHP also casts variables too boolean when required, 1 would cast to be
true, 0 to false.
So
if (1)
{
echo 1;
}
will indeed echo 1.
Previous Comments:
------------------------------------------------------------------------
[2009-02-04 16:58:26] saskia at sa5kia dot nl
Description:
------------
The information on the file_exists() function on
http://nl2.php.net/file_exists is very wrong. I spend
an hour to find
out what the problem of my script was, but your manual was the one that
was wrong. It sais the function gives a TRUE or a FALSE as an output,
but this is very incorrect. It outputs 1 or 0. This is absolutely not
the same on unix systems. TRUE or FALSE are boolean values, integers 1
or 0 are used for this a lot, but are INTEGERS. "If" statements in php
will NOT recognize the boolean and will not function correctly when
treated as one.
Please just say a function outputs 0 or 1, if it outputs 0 or 1.
Reproduce code:
---------------
$does_the_file_exist = "yes";
if ( ! file_exists( "some_not_an_existing_file" ) )
{
$does_the_file_exist = "no"
}
Expected result:
----------------
The value of $does_the_file_exist is "yes", but it should be "no".
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47307&edit=1
Thread (2 messages)