John Davidson

php - Codeigniter not echoing only when script end to run

0 comments
Message:


I'm facing some problem with CI4 when I doing a loop and running on terminal (php index.php) I not seeing the echo on live, only when the script finish to run than its printing all of those echo together. In the past in CI3 I was seeing every loop printing on live to the terminal screen:


$stop = 10000000000000000;

for($index_start=0;$index_start<$stop;$index_start+=10){
echo $index_start."\n";
}


My Answer:
= $stop; $index_start++){_
_ echo "Loop iteration: $index_start\n";_
_}_

_This issue might be related to output buffering in Codeigniter 4. You can try disabling output buffering in your controller method or in your index.php file by adding the following code:_

_ini_set('output_buffering', 'off');_

_You can also try using the flush() function after each echo statement to force the output to be sent to the terminal immediately:_

_for($index_start=0;$index_start < $stop; $index_start++){_
_ echo "Loop iteration: $index_start\n";_
_ flush();_
_}_

_Try these solutions and see if they help in getting the echo statements to be displayed immediately on the terminal screen while the script is running._

Rate this post

5 of 5 based on 3617 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us