Question:
how to run a php file?
anonymous
2013-02-09 23:05:06 UTC
How can we run a php file in a web browser
Six answers:
Mehul
2013-02-10 02:23:44 UTC
To run a PHP File in your web browser, you need a server like xampp or wamp. You can google it for downloading them.



Once downloaded, install it with the by-default server name => localhost.



Now, create a file of php in any of the editor like notepad.. Save it with the extension .php in the folder called www in the server. That www folder can be found in C: Drive if installed by-default. If you have chosen another drive for it while installing, you'll have to install it on that drive.



After saving the file, go to your web browser, in the address bar, type => localhost/"filename.php" where filename is the name of your file without quotation marks. If you have created a folder inside www folder, you will have to specify the name of the folder too like this => localhost/"foldername"/"filename.php" where your foldername is the name of the folder you have created inside the www folder.



Make sure that the name are case sensitive, so while writing the name of either the folder or file, they should be spelled correctly to avoid errors.



And hit enter and BINGO.

You just ran a php file..



Hope, i have helped you in finding what u had desired for..



Good Luck.
GenieUltimate
2013-02-10 07:17:52 UTC
The MOST very simple: On your computer open a windows console (or linux console, whatever OS you have) and type "php abc.php" where "abc.php" is your file. For this to run, you have to have PHP path in your "path" variable, otherwise you will get something like "no such program 'php'". If you're on windows, if your PHP is installed for example in "c:\php" then you need to type "c:\php\php.exe abc.php". If you're on linux, this won't be needed. It will be within the path I think.



Very simple: Just type the path to the file from the perspective of the web-server into the address bar of your browser.



Example: You got a web-hosting on "www.example.com". And you created "abc.php". And you copied this file into the main directory of your web-server site directory. Then you simply type "www.example.com/abc.php" in your web browser. If you rename your file to "index.php" you don't need to type its name, just the adress "www.example.com" as "index.whatever" is special name for the webservers, just like "main.whatever".



I guess your web host runs on Apache server, so you need to copy the php file to your "wwwroot" directory on the web-server.



Also important - the php file need to have "execute" and "read" attributes set for the user group of the web-server.



That's it. If you can't do it - it's time to read the books and the help files.



Good luck!



PS: Of course this is assuming your PHP program is working fine. Because if it's not and you run it in the web-server you will get HTTP Error 500 (which is "Internal Server Error") or a full description of the error, depending of how the web-server is configured to answer. If you get something like "Access Denied", then check your web-server directory permissions and the permissions of the file too.
ʄaçade
2013-02-10 07:13:37 UTC
php [options] [ -f ] file [[--] args...]



Php interactive mode allows you to try out your code snippets on the command line.

But it is usually easier to store your php code in a file and use the -f option. This is similar to the way a web server would do it.
Waleed
2013-02-10 07:08:49 UTC
pHp is actually run on the server, not the browser. You can use Html POST to access the file and pass it form information.
Siju
2013-02-11 11:04:47 UTC
Refer the below link



http://www.youtube.com/watch?v=ImZEwrHohRg



http://www.daniweb.com/web-development/php/threads/221906/how-to-run-php-files
anonymous
2013-02-10 08:08:48 UTC
get xampp.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...