jayarsee Posted August 26, 2010 Share Posted August 26, 2010 Hi, I was asking for help with this elsewhere, but after a week no one was able to answer my question so I thought someone here might be able to shed some light on it. My original question was: "I have an action that instantiates an object, and that object instantiates a bunch of child objects, and so on. My question is, do I only have to set set_time_limit() once in the action, in order to have that rule propagate to the execution of all of its child objects, or do I also have to set this in each of the class files that it calls? I similarly need to set ignore_user_abort() which I haven't used before, and I have the same question for that." To clear up confusion about what I was asking, I clarified this way: "That the limit applies to the "script" is the ambiguity I'm confused about. Technically, the original file is one script, so you set the timeout for that. But when it instantiates and object whose class code is coming from another file, that's a different "script", so presumably it could have its own timeout. And that's what my question is. Does the time out value you set automatically propagate to every other file that file calls on, or is it isolated to that file? If you set a time limit of 100 seconds, but instantiated an object from class code in a different file and called a long running method in it, and that file had a different time out, say of 30 seconds, the execution time of the original file would be limited to 30 seconds and not 100." In sum, do functions like ignore_user_abort() and set_time_limit() automatically apply to all code in the files a particular "script" require_once()'s? Or would it have to be set in those files as well? I would just test myself to find out, but the method I would use to do that would be sleep() and that time isn't counted toward set_time_limit() so it won't work. Thanks very much for any clarification someone might be able to give. Link to comment https://forums.phpfreaks.com/topic/211801-where-do-i-call-set_time_limit/ Share on other sites More sharing options...
AbraCadaver Posted August 26, 2010 Share Posted August 26, 2010 It applies to the beginning of code execution of a script until the end. So if you start scripta.php and it includes scriptb.php and instantiates an object or does whatever, then it applies to the entire sequence of events until the script ends. So putting it in the original scripts applies to the entire execution, so long as there is not another set_time_limit() in one of the other files. Link to comment https://forums.phpfreaks.com/topic/211801-where-do-i-call-set_time_limit/#findComment-1104008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.