简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM