PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 2, 2022

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

 July 02, 2022     php, xampp     No comments   

Issue

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


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.



Answered By - Quentin
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing