Eventhough the apache server is running, while running a php program written in notepad++ on a web browser, it displays the coding instead of output. How to solve the problem?
Asked
Active
Viewed 791 times
-1
-
what's the extension of file? and can you please put code you wrote? – Akshay Jan 25 '17 at 12:05
-
1Did you doubleclick the program file from within Explorer? PHP requires an interpreter to execute, that is only available if you have a web server(Apache) Configured to run php scripts and you launch the script from within the Browsers address bar eg (`localhost/myscript.php`) – RiggsFolly Jan 25 '17 at 12:06
-
Are you using `` instead of ` – A B Catella Jan 25 '17 at 12:18
-
1Possible duplicate of [PHP code is not being executed, instead code shows on the page](http://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-instead-code-shows-on-the-page) – Jarosław Kończak Jan 25 '17 at 12:51
2 Answers
1
PHP scripts cannot be run directly by a browser. The PHP interpreter has to process the PHP script first. For local development as a beginner try XAMPP (on Windows) for an easy to install and use web server with PHP enabled. PHP itself contains a builtin webserver too. To run it, change to your projects directory an execute
php -S localhost:8000
then open your browser and go to http://localhost:8000.
Jonas Köritz
- 2,564
- 20
- 32
-1
If you run the php file out of notepad, you have to change the url in the browser from /path/to/file/filename.php to localhost/filename.php.
Mr. K. O. Rolling
- 258
- 2
- 13