#47307 [Opn->Bgs]: Very wrong info in documentation

From: Date: Wed, 04 Feb 2009 17:53:28 +0000
Subject: #47307 [Opn->Bgs]: Very wrong info in documentation
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1802@lists.php.net to get a copy of this message
 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)

« previous php.doc.bugs (#1802) next »