Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I specify which php file to open in command prompt?

I’m creating a website project using php through xampp. I’ve followed through a tutorial online and have opened up my website through localhost:8000. My question is, when I open a php file through command prompt, how do I specify which file I want to be opened? (at the moment index.php is the file that is opened). Screenshot below.

Files and command prompt screenshot

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

To open a PHP file through the command prompt you type:

php nameOfFile.php

That isn’t what you are doing. You’re running the PHP built in web server. It doesn’t open index.php, it starts a web server.

When you request a URL from that server from your browser (or other HTTP client) then it will map the path of that URL onto a file.

i.e. if you type http://localhost:8000/foo.php then it will run foo.php and return the result in the HTTP response.

If you request a directory, then it will try to map that onto a file called index.php in that directory.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading