I have javascript code passing id to my php script in intervals of time, once the id is not being passed (it means the user has closed the javascript page). Block in if statement should run in php script. But this scenario is not happening with me.
Code is below
JavaScript
<script type="text/javascript" src="jquery-1.11.1.js"></script>
<script type="text/javascript" >
$(function(){
    // set interval for 5 second
    setInterval(function(){
            $.ajax({url: "test9.php?id=('1')"
            });
    }, 50000);
});
</script>
PHP
<?php
while(true)
{
    $id = $_GET['id'];
    if(isset($_GET['id']))
    {
        file_put_contents('/tmp/phptest1234.txt', 'test');
    }
    else
    {
        file_put_contents('/tmp/phptest.txt', 'test');
    }
}
?>