There is a file named cart.html.php on page 277 of the fifth edition of PHP & MYSQL: NOVICE TO NINJA. I’m assuming the header function on page 279 uses the name of that file as a part of the URL (?cart). Specifically, the code is:
The part of a URL that follows a question mark is a query string, which usually consists of parameters with assigned values.
Though in this case there is only a parameter name (cart) with no vaule.
A value will follow an = after the paramter name.
So you could have ?id=123 where the value of id is 123.
In PHP you can access these parameters and values via the $_GET array.
I could only find anything about an .htaccess file on page 188 in the edition I have, which is the fifth edition. I couldn’t tell if this type of file is only used with Apache servers.
I know that Apache does use it, and that the web server I’m more familiar with does not, but I don’t know whether other servers like IIS have an equivalent. What server are you using?
Having nothing before the ? will normally open the default home, and having nothing after the t could be a rewrite rule as I said above. I’m not sure whether just having the parameter specified, without a value, would allow it to be used in an isset() check in the destination page, too.
I don’t have the book so I can’t say what might or might not be happening.
I think I know why you asked that question, because of the value of the action attribute, which I think is in the URL used by the header function. Here is the code:
As explained, ?cart will not take you a file called cart.
The absence of anything before the ? means the file accessed will be index.php (or whatever the homepage is called), but with the query string cart appended to the URL, which will most likely be used in a condition like I posted.
The action="?" will make the form use the same URL as the form itself, but the absence of anything after the ? will remove any query string appended to the current form URL.
What I beleive this does is to allow a single controller file have a number of different outputs (such as display apparently different web pages) dependant on the query string, or lack of.
Thank you for comparing ? and “”. On page 127, it says that header('Location: .'); will also point to index.php. Would you please compare . with those two (? and “”)?
I think it’s correct to say that "." is shorthand for “the current directory”, in a similar way that ".." is shorthand for “the next directory level up”, i.e. the parent directory.