#37211 [Opn->Bgs]: require_once: a statement or a function?

From: Date: Wed, 26 Apr 2006 18:37:54 +0000
Subject: #37211 [Opn->Bgs]: require_once: a statement or a function?
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969372789@lists.php.net to get a copy of this message
ID: 37211 Updated by: vrana@php.net Reported By: idbaxter at semdesigns dot com -Status: Open +Status: Bogus Bug Type: Documentation problem Operating System: Windows PHP Version: Irrelevant New Comment: PHP manual definition of a statement: "A statement can be an assignment, a function call, a loop, a conditional statement or even a statement that does nothing (an empty statement)." require fits in this definition. Previous Comments: ------------------------------------------------------------------------ [2006-04-26 17:04:42] idbaxter at semdesigns dot com Description: ------------ The online manual clearly states that require_once (and related actions such as include) are *statements*. There is no documented return value. It also states that "if" is a *statement*. But actual code sample (from a running system) shows that require_once (and related actions such as include) can be used like a function (see attached code), and even odder, the "@" operator can suppress errors. Now, you can't do that with "if" statement. So, if require_once is a statement, you shouldn't be able to do that. If it is a function, it should be documented as such. So, is the following code wrong? Reproduce code: --------------- <?php if (! require_once /* require_once as a function */(APP_ROOT_DIR.'EcWebFramework/conf/Includes.php')) { $msg = 'Can not load Includes - check filesystem.'; error_log($msg); die($msg); } @include_once( $includePath ) ; /* @ supressess error */ if( !@include_once( $include_file ) ) / *both wierdnesses */ { $this->__errorAlert( 'TemplatePower Error: Couldn\'t include script [ '. $include_file .' ]!' ); exit(); } Expected result: ---------------- I expected to get a complaint about illegal syntax. Actual result: -------------- Above code runs without complaint. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37211&edit=1

« previous php.doc (#969372789) next »