If I make a PHP code loop since PHP is parsed first does that mean that the html in the page will never be executed until I exit the PHP loop. Is this the same with Javascript? Like the browser only reads one line at a time starting at the top with PHP right so it'll never get to the PHP and if it goes into a javascript loop it'll never get to the rest of the html code right?
The browser does not read PHP. PHP is processed serverside before being sent to the browser. If you don't suppress errors, IIRC PHP does have a maximum execution time configurable, when it hits that it should error out and spit out the rest of the page
you have a point there, but no.. there are two sides running scripts javascript -> frontend (browser) PHP -> serverside (apache) There will be no conflicts here because they are running in different environment. PHP error will halt the javascripts but not javascript stopping PHP, meaning the PHP (serverside) runs first.
Enable error_reporting(E_ALL) and try to put some debug handlers and / or log them to a file on the server. So this way even if you don't see what is happening in the loop on browser, you can see the log for info.
I like to tell you one thing here ... If you are creating an infinite loop inside php script and include it inside html it will not display any content as in server side the execution is not done yet. So make sure you dont have an infinite loop in php script .. otherwise you will get a blank page Thanks !
in PHP there's a function called flush(); as soon as you call flush it sends out all the available output from your php routine <?php for ($i=1; $i<=50; $i++) { echo $i . "<br />"; flush(); } ?> PHP:
If you use the output buffer all your code will execute then be sent to the browser therefore if your code never finished executing ie inf loop no output will be sent to your browser. if you print your code right after you execute it then each print will be sent to your browser.