Wednesday, September 1, 2010

PHP Include

Server Side Includes (SSI) are used to create functions, headers, footers, or elements that will be reused on multiple pages.

Server Side Includes
  • You can insert the content of a file into a PHP file before the server executes it, with the include() or require() function. The two functions are identical in every way, except how they handle errors. The include() function generates a warning (but the script will continue execution) while the require() function generates a fatal error (and the script execution will stop after the error).
  • These two functions are used to create functions, headers, footers, or elements that can be reused on multiple pages.
  • This can save the developer a considerable amount of time. This means that you can create a standard header or menu file that you want all your web pages to include. When the header needs to be updated, you can only update this one include file, or when you add a new page to your site, you can simply change the menu file (instead of updating the links on all web pages).
  • Include_once and require_once is also use for include any file into your code.
  • But the difference between include and include_once is in include if there is any error in include file there is no effect on the code where it isincluded but in include_once there is effect in the code if there is any error.

























It is recommended to use the require() function instead of include(), because scripts should not continue executing if files are missing or misnamed.

No comments:

Post a Comment