Portfolio

Facebook App, Mobile, and Web Developer
  • about
  • blog

Include or Require

Feb. 12, 2009 Uncategorized / 0 Comments

Recently, Jayson, one of my colleague asked me what the difference was between include and require in PHP. I had no idea, so I discussed with Oskar, another back-end developer, and he was not clear about that as well. Until yesterday, I was reading some PHP documentation about Smarty, then I grasped the differences. Basically there are four kinds of include/require methods in PHP, require, require_once, include, and include_once. They are built for PHP pages to load other files. If the function comes with ”once” as a post-fix, that means the PHP interpreter will ensure the file you want to load only loaded once on that page. Finally, the biggest difference between include and require is when the loaded file cannot be found, require will throw an error, but include won’t.
It was until I had written this post that I realized the exact same information I happened upon on Smarty, was written on the PHP menu. I should”ve read the menu first.

http://us.php.net/require

http://us.php.net/manual/en/function.include.php

No Comments »

Leave a comment

Cancel Reply

Copyright © 2011. All Rights Reserved.