Home of web learners
www.webn3rd.com
If you something common in many webpage then you can use include or require
Lets say you see that in every page of a website the menu is same,wherever you go of a website like in different page,same menu appears
So its not good to write same code for showing menu in different page better to use one menu code to all page by linking
By include or require you can do it
lets start with include
Lets look an example of include
Here,you see that we include a script named menu.php where code for showing menu exists,so you don't have to write menu code for all pages of a site,just use this line which add menu to all pages
After this you can use your other code for your webpage as your need,you can use include anywhere in webpages where you need to add a script by linking,it works like all code of inclued scipt are working there with a single line
Now what about require,its the same thing as include works
lets look an example
you see that example of include and require are same,so whats the difference?
Difference is include shows warning error if the script not found like here menu.php and require shows fatal error
But in require example,if script file in require not found or missing then code after it not going to execute and here this is homepage will not show
webn3rd.com