php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67683 var_dump() makes the following codes execute twice
Submitted: 2014-07-25 11:11 UTC Modified: 2014-07-26 01:45 UTC
From: enadiz at foxmail dot com Assigned:
Status: Closed Package: Output Control
PHP Version: 5.5.15 OS: Linux 3.13.0-24-generic #Ubuntu
Private report: No CVE-ID: None
 [2014-07-25 11:11 UTC] enadiz at foxmail dot com
Description:
------------
The example A runs correctly .It's output on browse is like this
: int(0) test
and the output in file "test.txt" is
:
1406285601


The example B doesn't runs correctly .It's output on browse is 
: int(0) test 
    which with no problem
but the output in file "test.txt" is like that
:
1406285917
1406285919
    it means that all the codes executed twice except the line contains "echo".I try replaced "file_put_contents " to other operation likes mysql's insert ,it  still executed twice and the database inserted two records;

Test script:
---------------
<?php    //example A
sleep(2);
echo 'test';
file_put_contents("test.txt",time()."\r\n", FILE_APPEND);
?>



<?php   // example B which some codes execute twice
var_dump(0);
sleep(2);
echo 'test';
file_put_contents("test.txt",time()."\r\n", FILE_APPEND);
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-25 16:34 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2014-07-25 16:34 UTC] requinix@php.net
If you're only seeing the "int(0) test" once then the script is only executing once. It may have executed previously, like if you forgot that test.txt is being appended to, or the browser may have executed it twice (Chrome sometimes does this), but PHP itself is not doing it.

What if you dump $_SERVER["REQUEST_TIME_FLOAT"] to the file? Does it put the same number or two different numbers? What do your server access logs show?
 [2014-07-26 01:45 UTC] enadiz at foxmail dot com
-Status: Feedback +Status: Closed
 [2014-07-26 01:45 UTC] enadiz at foxmail dot com
It is not php's problem ,because of that the Chrome would reload the page when var_dump executed
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Apr 05 01:01:24 2020 UTC