'Is that efficient way of using require

So basically the question when I'm making a website is that efficient way of doing to use 3 require PHP functions to call some of my static elements :

  1. first one to my navbar and links to css stylesheets
  2. second on the bottom of the page for footer
  3. the third one to file where I have links to my scripts

Do you use other methods than require or include or this is a good way of doing this



Solution 1:[1]

The include and require statements are identical, except upon failure:

  • require will produce a fatal error E_COMPILE_ERROR and stop the script.
  • include will only produce a warning E_WARNING and the script will continue.

Solution 2:[2]

I would strongly recommend using autoloader as described here Using php Autoloader and wrap your functionality using Classes it will produce much cleaner and easier to maintain php code, even for small projects as it leaves options for using third party extensions such as Facebook or Paypal later on.

Try to differentiate between Output, Input and functionality it doesn't have to resemble MVC but it's a good practice.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 George Dryser