ID: 24967
User updated by: laurie at oneuponedown dot co dot uk
Reported By: laurie at oneuponedown dot co dot uk
Status: Bogus
Bug Type: *Directory/Filesystem functions
Operating System: Linux
PHP Version: 4.3.2
New Comment:
The prior example does not imply a bug I agree, incorrect
example SORRY half asleep.
The following example recreates the problem experienced.
Whilst the following arrangement may appear redundant this
is obviously a reduced version of the actual code.
<?
class test {
var $ID;
var $OUTPUT;
function test() {
return $this->test2();
}
function test2() {
// OPEN OUTPUT_FILE FOR READING
$this->ID =
@fopen("/tmp/213.212.78.27.1060201522.txt","rb");
if ($this->ID) {
$OUTPUT = fgets($this->ID);
return TRUE;
} else {
$OUTPUT = "ERROR";
return FALSE;
}
}
}
$TEST = new test();
print_r($TEST);
?>
Expected Output:
test Object
(
[ID] => Resource id
[OUTPUT] => (FIRST LINE OF FILE OR ERROR)
)
Actual Output:
test Object
(
[ID] => Resource id
[OUTPUT] =>
)
Fopen opens resource but then causes function to return
with none of the code following it within the test2
function being executed. Removing fopen results in all of
the test2 function code being executed. Popen also causes
the same issue.
Previous Comments:
------------------------------------------------------------------------
[2003-08-06 16:33:50] [EMAIL PROTECTED]
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
Remove the @ from the fopen() call, and then go read the manual.
------------------------------------------------------------------------
[2003-08-06 16:13:53] laurie at oneuponedown dot co dot uk
Description:
------------
When using fopen inside a function to open a file for
reading - irrerspective of weather fopen successfully opens
the file, the use of fopen causes the function to return.
Reproduce code:
---------------
<html>
<head>
<title>TEST</title>
</head>
<body>
<?
function test () {
// OPEN FILE FOR READING
if ($ID = @fopen("/tmp/213.212.78.27.1060201522.txtfgbxdf","wb")) {
// NOTHING FROM HERE DOWNWARDS IS EXCUTED
// PRINT FIRST LINE OF FILE
print(fgets($ID));
} else {
// PRINT ERROR
print("FOPEN FAILED");
}
}
?>
</body>
</html>
Expected result:
----------------
First line of file if success, "FOPEN FAILED" if fail.
Actual result:
--------------
Nothing
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24967&edit=1