I'm kind of confused.
I would put all the HTML for the menu in a .php file and have the engine require it right?
I'm kind of confused.
I would put all the HTML for the menu in a .php file and have the engine require it right?
Dunno what do you call "loads correctly", but yes, you can put all the HTML for the menu in a .php file and have the engine require it
According to the manual, the require() function will produce a fatal error if it cannot find the required file. So, if you require() the menu and the menu file is not present, you page will not show.
But if the menu file is found and contains errors, the page will show them.
require_once()
, and more specifically require()
in general, will throw a fatal error (which will cause the page to stop loading) if the file does not exist. If there is an error in the file itself, require()
will not change what happens. require_once()
(and include_once()
) are used in the case that you might have two or more files that need the same file to work. Basically, the _once
functions will not let the same file be included multiple times (which is good, because you cannot redeclare functions and such).
Instead of using require() to load blocks of HTML, just use:
print file_get_contents('html/menu.html');
These are the four basic possibilities:
Of course, in normal circumstances, there should never be errors ;-)