Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output HTML from PHP CLI execute

I hope this question makes sense - it might be that I don't fully understand what is going on.. but after a considerable amount of googling to no avail here goes:

What I'm trying to do is execute a PHP file on the command line using php filename.php and get the output as HTML - so it could be displayed as a webpage. Currently the command line is just returning raw text output with no HTML tags. Currently the only line of code in PHP file is: <?php phpinfo() ?>

Is this possible? If not, how does MAMP etc execute that file to produce a HTML output?

Thanks!

like image 999
cud_programmer Avatar asked Oct 31 '25 20:10

cud_programmer


1 Answers

If you use php-cgi instead of php from the CLI your program will run as if it were running on a webserver. It won't have access to anything in $_SERVER, $_POST, $_GET etc but it will cause phpinfo() to produce HTML instead of plain text.

like image 66
muglio Avatar answered Nov 03 '25 23:11

muglio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!