PDA

View Full Version : includes errors...


meowmeow
06-08-2004, 12:15 PM
whats the difference between include/include_once/require/require_once

I have several scripts and to simplify things i put them all in one script like so

include (foo.php)
echo foo()

include (bar.php)
echo bar()
and so on...
the first one runs fine then it starts telling me i cant redeclare things from the 2nd one on! basically if I have an include(hello); in foo.php and in bar.php when it gets to bar.php it gives me the error.... how do i fix this??

Velocd
06-10-2004, 02:31 AM
include_once and require_once are simliar to #ifndef, #define, and #endif C++, to ensure you don't include a resource file more than once, thus preventing function redeclare errors.

It's wise to always use include_once or require_once.