Re: require() vs include()
| From: | Jim Lucas [php] | Date: | Fri, 15 Mar 2002 00:54:34 +0000 |
| Subject: | Re: require() vs include() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-88600@lists.php.net to get a copy of this message | ||
Plus, depending on how you are calling the file. Meaning if the file name
that you are calling is a static file name or dynamic file name
require() and require_once() will include a file before the php parser
starts its job, but this will only happen if the name isn't dynamic.
meaning that if you have this
require("myfile.inc"); //static
and
require($var. ".inc"); //dynamic
the first one will be included into the before parsing and the second will
wait until the parser comes along and defines the $var value.
if you call require() or require_once() with a variable in the file handler
name space, it will downgrade (in a way) to just working like an include()
or include_once()
with include() or include_once() it doesn't matter if the file handle name
has a variable in it. it will always include the file after the parser
starts its job.
Jim Lucas
www.bend.com
----- Original Message -----
From: "SHEETS,JASON (Non-HP-Boise,ex1)" <jason_sheets@non.hp.com>
To: "'David McInnis'" <david@dataovation.com>;
<php-general@lists.php.net>
Sent: Thursday, March 14, 2002 3:56 PM
Subject: RE: [PHP] require() vs include()
> They are much the same, both "include" a file.
>
> To quote the PHP manual "require() and include() are identical in every
way
> except how they handle failure. include() produces a Warning while
require()
> results in a Fatal Error. In other words, don't hesitate to use require()
if
> you want a missing file to halt processing of the page. include() does not
> behave this way, the script will continue regardless. Be sure to have an
> appropriate include_path setting as well."
>
> That said I would use require_once and include_once instead of just
include
> and require, these functions ensure the file is only included once which
> prevents a lot of problems.
>
> Jason
>
> -----Original Message-----
> From: David McInnis [mailto:david@dataovation.com]
> Sent: Thursday, March 14, 2002 4:47 PM
> To: php-general@lists.php.net
> Subject: [PHP] require() vs include()
>
>
> Are these redundant functions or are they different? I seem to be able
> to use the interchangeably.
>
> David McInnis
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>