For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > April 2006 > #37211 [Opn->Bgs]: require_once: a statement or a function?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #37211 [Opn->Bgs]: require_once: a statement or a function?
vrana@php.net

2006-04-26, 6:59 pm

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com