From: [EMAIL PROTECTED]
Operating system: Linux
PHP version: 4.3.0
PHP Bug Type: Scripting Engine problem
Bug description: return behaviour differs between include and require
when a return is made out of an included file (using
include), the value is properly returned. However, using
the require statement instead results in values not being
preperly returned from a return statement in included
code.
Example
This function currently exists in a class and works.
function execQuery( &$sql, $result_status, $file, $line )
{
return include( dirname( __FILE__
)."/execQuery.php" );
}
This function DOES NOT WORK when I attempt the use the
result it is not defined.
function execQuery( &$sql, $result_status, $file, $line )
{
return require( dirname( __FILE__
)."/execQuery.php" );
}
This is the contents of the file it includes
<?php
$this->validateFileConstants( $file,
$line, __FILE__, __LINE__ );
if ( !is_string( $sql ) ) {
$this->{$this->log_func} ( "File: $file. Line:
$line. \$sql is NOT a string. (%s, %d)",__FILE__, __LINE__
);
}
if ( !is_int( $result_status ) ) {
$this->{$this->log_func} ( "File: $file. Line:
$line. \$sql is NOT a string. (%s, %d)", __FILE__,
__LINE__ );
}
if ( $this->conn == NULL ) {
$this->{$this->log_func} ( "File: $file. Line:
$line. \$conn not open. (%s, %d)", __FILE__, __LINE__ );
}
if ( pg_result_status( $rs = pg_query ( $this->conn,
$sql ) ) !== $result_status ) {
/*pg_query returns false, can't use result_error.*/
$this->{$this->log_func} ( "File: $file. Line:
$line. Error executing. \"%s\" (%s, %d)"
, pg_last_error(), __FILE__,
__LINE__ );
}
return $rs;
?>
This behavious is also inconsistent with tjhe document
which reads that the onyl difference if a warning or Fatal
Error.
Josh.
--
Edit bug report at http://bugs.php.net/?id=21725&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=21725&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=21725&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=21725&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=21725&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=21725&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=21725&r=support
Expected behavior: http://bugs.php.net/fix.php?id=21725&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=21725&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=21725&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=21725&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21725&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=21725&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=21725&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=21725&r=gnused