Die/exit/close script execution after 10 seconds ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Die/exit/close script execution after 10 seconds ?

    i need such code to force php script execution to close after 10 seconds
    got some bugy php class for gif resize and on some' of them it keeps you waiting 'till maxim execution time is exceeded
    x_X don't tell me to set maxim execution time to 10 seconds because my server ignore settings like ini_set or php.ini ... .htaccess

    it is possible to make such function based on session or something ?

    please share some thots here . tnx ya '.
    This is ten percent luck, twenty percent skill
    Fifteen percent concentrated power of will
    Five percent pleasure, fifty percent pain

    And a hundred percent reason to remember the name!

    #2
    PHP Code:
    set_time_limit(10); 
    Does it work?

    Added after 3 minutes:

    or something like this:

    PHP Code:
    $start time();
    for(;;){
        if((
    time()-$start)>=10) exit("FINITO!");

    Last edited by GumSlone; 07.03.12, 20:34.
    Advertise your mobile site for FREE with AdTwirl

    Comment


      #3
      FINITO! hell ya !

      Tnx a lot ..
      This is ten percent luck, twenty percent skill
      Fifteen percent concentrated power of will
      Five percent pleasure, fifty percent pain

      And a hundred percent reason to remember the name!

      Comment


        #4
        Originally posted by GumSlone View Post
        or something like this:

        PHP Code:
        $start time();
        for(;;){
            if((
        time()-$start)>=10) exit("FINITO!");

        Will this cause execution time always to be 10 seconds? (infinitive loop)

        Comment


          #5
          Originally posted by something else View Post
          Will this cause execution time always to be 10 seconds? (infinitive loop)
          well you have to place your code into the loop, it depends on what type of code you place inside it, for example if you try to convert a big video file (conversion time of which is much longer than 10 seconds) this will not work, but if you for example want to grab multiple files or do some multiple short similar processes this will work.
          Advertise your mobile site for FREE with AdTwirl

          Comment


            #6
            Originally posted by GumSlone View Post
            well you have to place your code into the loop, it depends on what type of code you place inside it, for example if you try to convert a big video file (conversion time of which is much longer than 10 seconds) this will not work, but if you for example want to grab multiple files or do some multiple short similar processes this will work.
            yup already done that :p , it works , but i've got to make some mods there , anyway tnx for the idea ! , and yeah the code must be in the loop .. .
            This is ten percent luck, twenty percent skill
            Fifteen percent concentrated power of will
            Five percent pleasure, fifty percent pain

            And a hundred percent reason to remember the name!

            Comment


              #7
              so something onlines of:
              Code:
              $loadgif = false;
              $start = time(); 
              for(;;){  // for loop has to be above the loadgif function or it wont get executed? ... or will this cause loadgif not to be executed?
                  if((time()-$start)>=10) exit("FINITO!"); 
                  if($loadgif!=false) break;
              } 
              
              $loadgif = loadgif();

              Comment


                #8
                only this will work

                PHP Code:
                $loadgif false;
                $start time(); 
                for(;;){
                    
                $loadgif loadgif();
                    if((
                time()-$start)>=10) exit("FINITO!"); 
                    if(
                $loadgif!=false) break;

                Advertise your mobile site for FREE with AdTwirl

                Comment

                Working...
                X