RE: [PHP] Require_once problem
Well, the way I've read it is that if you use require within control structures then all files are included, regardless of whether the script exits before it reaches its next if...elseif...else or case statement. With include that does not happen. So the general rule of thumb would be to use require() if you are not using it within these control structures, and use include() if you actually do need to use include statements in your control structures. Now, that said, I'm really not sure if that is true for the require_once and include_once functions also. You might want to look into that. Hope this helps a little. -- Darwin -Original Message- From: Kerry Kobashi [mailto:kkobashi;thegrid.net] Sent: Friday, November 01, 2002 1:36 AM To: [EMAIL PROTECTED] Subject: [PHP] Require_once problem Whats the difference between require_once and include_once? I been running into a problem, perhaps someone can help. I require_once in a Pear database extension. Inside that pear database extension is a require_once(pear.php) and a require_once(db.php) This file, Thomas Voxs' DbPage.php file, gets require_once inside yet another file (my file). The problem is, my file brings in many require_once file's, some of which require_once(db.php) inside of it. All I get redefinition problems all over the place. It appears to me that require_once doesn't work as advertised? For if it did, there should never be redefinition problems. Why didn't all PHP code do like we do in C/C++ with #define BLAH if !defined(BLAH) { your code here. } I realize the #define trick works as I used it in my own PHP code... but when the basic PHP core files don't have this in them, it sort of makes require_once and include_once hacks! (that don't work) Any ideas suggestions? -- 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
RE: [PHP] Require_once problem
-Original Message- From: Darwin [mailto:superbus22;attbi.com] Sent: 01 November 2002 10:17 Well, the way I've read it is that if you use require within control structures then all files are included, regardless of whether the script exits before it reaches its next if...elseif...else or case statement. With include that does not happen. So the general rule of thumb would be to use require() if you are not using it within these control structures, and use include() if you actually do need to use include statements in your control structures. That's how it *used* to work (somewhere back around 4.0.3, if memory serves). Now, the only difference is that the require versions will produce a fatal error if the file is not present, whereas the include versions will only generate a warning. Cheers! Mike Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Beckett Park Tel: extn 4730Fax: extn 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Require_once problem
Whats the difference between require_once and include_once? I been running into a problem, perhaps someone can help. I require_once in a Pear database extension. Inside that pear database extension is a require_once(pear.php) and a require_once(db.php) This file, Thomas Voxs' DbPage.php file, gets require_once inside yet another file (my file). The problem is, my file brings in many require_once file's, some of which require_once(db.php) inside of it. All I get redefinition problems all over the place. It appears to me that require_once doesn't work as advertised? For if it did, there should never be redefinition problems. Why didn't all PHP code do like we do in C/C++ with #define BLAH if !defined(BLAH) { your code here. } I realize the #define trick works as I used it in my own PHP code... but when the basic PHP core files don't have this in them, it sort of makes require_once and include_once hacks! (that don't work) Any ideas suggestions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php