Professional Web Applications Themes

#24967 [Bgs]: fopen when placed within a function causes function to return - PHP Development

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 ...

  1. #1

    Default #24967 [Bgs]: fopen when placed within a function causes function to return

    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]wezphp.net[/email]

    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 [url]http://www.php.net/support.php[/url] 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 [url]http://bugs.php.net/?id=24967&edit=1[/url]

    laurie at oneuponedown dot co dot uk Guest

  2. #2

    Default #24967 [Bgs]: fopen when placed within a function causes function to return

    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:

    New example also incorrect - $OUTPUT not class defined
    $this->OUTPUT, once this is corrected this example does not
    exhibit the bug. I will update once I have an example.


    Previous Comments:
    ------------------------------------------------------------------------

    [2003-08-07 05:14:09] laurie at oneuponedown dot co dot uk

    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.

    ------------------------------------------------------------------------

    [2003-08-06 16:33:50] [email]wezphp.net[/email]

    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 [url]http://www.php.net/support.php[/url] 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 [url]http://bugs.php.net/?id=24967&edit=1[/url]

    laurie at oneuponedown dot co dot uk Guest

Similar Threads

  1. #24967 [NEW]: fopen when placed within a function causes function to return
    By laurie at oneuponedown dot co dot uk in forum PHP Development
    Replies: 0
    Last Post: August 6th, 09:14 PM
  2. note 33763 added to function.fopen
    By firestar@alaska.net in forum PHP Notes
    Replies: 1
    Last Post: July 7th, 10:18 AM
  3. Function/Global var to return name of calling function?
    By Daniel Hansen in forum PHP Development
    Replies: 3
    Last Post: July 6th, 12:32 PM
  4. note 33721 added to function.fopen
    By nabsk2@hotmail.com in forum PHP Notes
    Replies: 0
    Last Post: July 5th, 12:59 AM
  5. note 33652 added to function.fopen
    By scorpios@vsnl.com in forum PHP Notes
    Replies: 0
    Last Post: July 3rd, 04:14 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139