Re: need help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Awesome explanation dude.... :)


Chaitanya

"A man can get discouraged many times but he is not a failure until he stops
trying..."



On Sun, Feb 14, 2010 at 8:03 PM, jasim ali khan <jasim_kust@xxxxxxxxx>wrote:

>
>
> Dear Here is your Problem Sol.
>
>
> Set the number of seconds a script is allowed to run. If this is reached,
> the script returns a fatal error. The default limit is 30 seconds or, if it
> exists, the max_execution_time value defined in the php.ini.
> When called, set_time_limit() restarts the timeout counter from zero. In
> other words, if the timeout is the default 30 seconds, and 25 seconds into
> script execution a call such as set_time_limit(20) is made, the script will
> run for a total of 45 seconds before timing out.
>
> (Below is the script may be its help you dear)
>
> <?php
> set_time_limit(2);
> ?>
>
> to the beginning of the script. Unfortunately, even two seconds of run time
> produced enough output to overload the memory available to my browser.
>
> So, I wrote a short routine which would limit the execution time, and also
> limit the amount of output returned. I added this to the beginning of my
> script and it worked perfectly:
>
> <?php
> set_time_limit(2);
>
> ob_start();     // buffer output
>
> function shutdown () {
>     // print only first 2000 characters of output
>     $out = ob_get_clean();
>     print substr($out, 0, 2000);
> }
>
> register_shutdown_function('shutdown');
> ?>
>
> If you use Apache you can change maximum execution time by .htaccess with
> this line
>
> php_value max_execution_time 200
>
> You can do set_time_limit(0); so that the script will run forever - however
> this is not recommended and your web server might catch you out with an
> imposed HTTP timeout (usually around 5 minutes).
>
> You should check your web server's guides for more information about HTTP
> timeouts.
>
> (Here some other script which helps you).
>
> When using the set_time_limit() function, the browser will stop after about
> 30 seconds if it does not get new data. To prevent this, you can send every
> 10 seconds a little snippet of data (like a single character) to the
> browser. The code below is tested with both Internet Explorer and Firefox,
> so it will stay online all the time.
>
> You should also create a file called chatdata.txt which contains the last
> thing said on a chatbox. Please note that you can also replace this function
> with a MySQL or other database function...
>
> <?php
>
> set_time_limit(900);
>
> // Start output buffering
> ob_start();
>
> $message = "First test message";
> $oldmessage = "bla";
>
> // Keep on repeating this to prevent PHP from stopping the script
> while (true)
> {
>     $timeoutcounter = 0;
>     while ($message == $oldmessage)
>     {
>         // If 10 seconds elapsed, send a dot (or any other character)
>         if ($timeoutcounter == 10)
>         {
>             echo ".";
>             flush();
>             ob_flush();
>             $timeoutcounter = 0;
>         }
>         // Timeout executing
>         sleep(1);
>         // Check for a new message
>         $message = file_get_contents("chatdata.txt");
>         $timeoutcounter++;
>     }
>
>     // Keep the old message in mind
>     $oldmessage = $message;
>
>     // And send the message to the user
>     echo "<script>window.alert(\"" . $message . "\");</script>";
>
>     // Now, clear the output buffer
>     flush();
>     ob_flush();
> }
>
> ?>
>
>
> [Non-text portions of this message have been removed]
>
>  
>


[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux