php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #47307 Very wrong info in documentation
Submitted: 2009-02-04 16:58 UTC Modified: 2009-02-04 17:53 UTC
From: saskia at sa5kia dot nl Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: NetBSD
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: saskia at sa5kia dot nl
New email:
PHP Version: OS:

 

 [2009-02-04 16:58 UTC] 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".


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-04 17:53 UTC] preinheimer@php.net
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.



 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 01:00:02 2026 UTC