Hoppus Posted September 14, 2008 Share Posted September 14, 2008 ok well, i'm slowly trying to learn the concept of required. i get it. but i guess i'm using the code wrong. what i understand it's supposed to do, is if a required errors, then nothing after that executes. correct me if that's wrong. the code i'm using is. require('lol.php'); echo $cfock; echo $b.$b.$a.$b . "bub"; and this is the output Notice: Undefined variable: cfock in H:\Program Files\EasyPHP 2.0b1\www\index.php on line 7 lol bub yeah there is no cfock, so it's supposed to error. but i thought it wasn't supposed to execute the echos if that errors? ;s Quote Link to comment https://forums.phpfreaks.com/topic/124232-required-thingy/ Share on other sites More sharing options...
Adam Posted September 14, 2008 Share Posted September 14, 2008 Do you have error reporting switched off at all? Quote Link to comment https://forums.phpfreaks.com/topic/124232-required-thingy/#findComment-641523 Share on other sites More sharing options...
Mchl Posted September 14, 2008 Share Posted September 14, 2008 It's a Notice, not an Error or Warning. Notices don't stop script execution. Quote Link to comment https://forums.phpfreaks.com/topic/124232-required-thingy/#findComment-641526 Share on other sites More sharing options...
Adam Posted September 14, 2008 Share Posted September 14, 2008 Not according to many articles I've read.. include should throw a notice, but require should cause an error... http://discomoose.org/2006/04/28/the-difference-between-require-and-include/ Just an example from one of the top results off google... Adam Quote Link to comment https://forums.phpfreaks.com/topic/124232-required-thingy/#findComment-641528 Share on other sites More sharing options...
Mchl Posted September 14, 2008 Share Posted September 14, 2008 Apparently lol.php exists in this case, and was included. Quote Link to comment https://forums.phpfreaks.com/topic/124232-required-thingy/#findComment-641531 Share on other sites More sharing options...
Hoppus Posted September 14, 2008 Author Share Posted September 14, 2008 yeah lol.php does exist but the variable doesn't O-o Quote Link to comment https://forums.phpfreaks.com/topic/124232-required-thingy/#findComment-641533 Share on other sites More sharing options...
Mchl Posted September 14, 2008 Share Posted September 14, 2008 As I said. Undeclared variable will trigger only a Notice, and the script will not stop on that. Quote Link to comment https://forums.phpfreaks.com/topic/124232-required-thingy/#findComment-641536 Share on other sites More sharing options...
Hoppus Posted September 14, 2008 Author Share Posted September 14, 2008 o mk cool cool so you think you can tell me the difference between an error and... whatever else there is? Quote Link to comment https://forums.phpfreaks.com/topic/124232-required-thingy/#findComment-641550 Share on other sites More sharing options...
Mchl Posted September 15, 2008 Share Posted September 15, 2008 Everyone makes mistakes in their code. Some are more serious, some are less. Some make script unable to run properly. Some will only increase the chances of something going wrong. That's why there are different levels of error reporting. Here are different types of errors explained: http://www.php.net/manual/en/errorfunc.constants.php Quote Link to comment https://forums.phpfreaks.com/topic/124232-required-thingy/#findComment-641767 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.