PHP

PHP is a kind of server side scripting that runs and compiles your page when you visit the url. The page doesn't actually exist in any form until you query for that page. Some times you might see a page that is named with a url that ends with "?page=12" - the line "?page=12" would mean it would be querying the script on what happens when page number equals 12.

Include & Require
In this example, if you had two files, respectively named vars.php and test.php, with this content, you should be able to see how the include works.

In the file "vars.php":


In the file "test.php":


When the echo is first run, it only returns A because vars.php has not yet been included. only after the line that says include vars.php, then will the next echo line also return the variables it has gotten from inside vars.php - namely that now it knows that the variable "color" has the value "green" and the variable "fruit" has the value "apple". This is the basic mechanism behind how content management systems put together your page when you go to that URL.

Similarly, require works in the same way, except that it is stricter in that it will break and stop the code from running if the file that is required does not actually exist.