jemz — 2012-09-28T09:56:40-04:00 — #1
Hi,can anyone enlighten my mind,when should i use the include_once and the required_once..and what is the difference on this two.Thank you in advance.
richardaskew — 2012-09-28T11:46:36-04:00 — #2
You would use them to include another file. A common example is to use include_once('header.php') on each page, so you just have to maintain one header file (Makes it easier to add/remove links).
They both essentially do the same thing but if you use require, the file HAS to be available or you receive a fatal error whereas include_once will try to include it but if it can't find it the page will still render.
tomb — 2012-09-28T12:02:59-04:00 — #3
In practice, if you're trying to include a file which doesn't exist then you're probably doing something wrong. In most cases, you'll want to use Require.
jemz — 2012-09-28T13:13:55-04:00 — #4
@TomB @RichardAskew, .Thank you for the reply and i will write it again if i have in doubt.