EmperorcJ Posted November 21, 2007 Share Posted November 21, 2007 Is there a way to ignore parse errors when calling an include? That is, the script calls include("file.php"), but if file.php has a parse error, the script just ignores the include and moves on. If you need specifics, I'm running an AIM bot and I have it so I can update part of the bot's functionality while it's still running. It looks something like this: ... while(1) { // check for new data ... // respond to data include("flamingcactus.php"); } And the included file looks something like this: ... if($message=="asdfghjk") sendIM("what"); else if($message=="etrtyhfds") sendIM("oh"); ... Every now and then I'll make a typo though and the whole program will crash, and I'll have to restart the bot and log in again. I'd rather just ignore the included file. Try/catch didn't work. I running php 5.2.5 on a windows machine. Quote Link to comment https://forums.phpfreaks.com/topic/78223-ignore-parse-error-on-include/ Share on other sites More sharing options...
LemonInflux Posted November 21, 2007 Share Posted November 21, 2007 If there's an error to ignore, put @ on the start of the line you think there may be an error. That way, errors are hidden for that line. Quote Link to comment https://forums.phpfreaks.com/topic/78223-ignore-parse-error-on-include/#findComment-395844 Share on other sites More sharing options...
EmperorcJ Posted November 21, 2007 Author Share Posted November 21, 2007 Nah I tried that too. @include("file.php"); terminates the program if there's a parse error in file.php Quote Link to comment https://forums.phpfreaks.com/topic/78223-ignore-parse-error-on-include/#findComment-395848 Share on other sites More sharing options...
EmperorcJ Posted November 21, 2007 Author Share Posted November 21, 2007 Be warned that parse error in included file doesn't cause processing halting in PHP versions prior to PHP 4.3.5. Since this version, it does. --PHP.net Are there other options besides downgrading? Quote Link to comment https://forums.phpfreaks.com/topic/78223-ignore-parse-error-on-include/#findComment-395850 Share on other sites More sharing options...
LemonInflux Posted November 21, 2007 Share Posted November 21, 2007 Nah I tried that too. @include("file.php"); terminates the program if there's a parse error in file.php I meant putting the @ in file.php. Quote Link to comment https://forums.phpfreaks.com/topic/78223-ignore-parse-error-on-include/#findComment-395857 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.