Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run php files on my computer

Tags:

php

apache

Could anyone please tell me how to run a php file locally on my system.
Currently I am using a server to run files.
I know both php & Apache to be installed.
I need to see out put of this program, for example:

<?php  $a=5; $b=10; $c=$a+$b; print $c; ?> 

Can you please tell how I can run these files of if I need anything more.

like image 483
logan Avatar asked Dec 20 '11 18:12

logan


People also ask

How do I run PHP code on my computer?

If you want to run a PHP file in the browser on your own computer, you'll need to set up a PHP development stack. You'll need at least PHP, MySQL, and a server like Apache or Nginx. MySQL is used to set up databases your PHP applications can work with.


1 Answers

php have a easy way to run a light server:
first cd into php file directory, then

php -S 127.0.0.1:8000 

then you can run php

like image 60
peter zhang Avatar answered Oct 14 '22 15:10

peter zhang