Is there any function in PHP like setTimeout with same functionallity in javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • balakrishnan.dinesh@gmail.com

    #1

    Is there any function in PHP like setTimeout with same functionallity in javascript

    hi frnds,

    Is there any function in PHP like setTimeout with same
    functionallity in javascript ..
    Thing is, In php we have a function call settimeout for socket , But i
    need the same functionallity of settimeout( ) fucntion of javascript in
    PHP, Is that anything available in PHP. Is there plzzzzz reply me quick

    Thank
    Dinesh..

  • P Pulkkinen

    #2
    Re: Is there any function in PHP like setTimeout with same functionallity in javascript

    <balakrishnan.d inesh@gmail.com wrote:
    Is there any function in PHP like setTimeout with same
    functionallity in javascript ..
    Thing is, In php we have a function call settimeout for socket , But i
    need the same functionallity of settimeout( ) fucntion of javascript in
    PHP, Is that anything available in PHP. Is there plzzzzz reply me quick
    Perhaps it would help people to help if you described the actual problem
    that needs the solution.
    Because if you compare php and javascript like that, there is usually a big
    difference:

    - javascript can manipulate page through dom object model and do things on
    it again and again until user goes to another page.
    - php _usually_ outputs a page, does some things in serverside and that's
    it - goodbye, mypage!



    Comment

    • balakrishnan.dinesh@gmail.com

      #3
      Re: Is there any function in PHP like setTimeout with same functionallity in javascript


      Hi,

      My exact problem is, i want to call a function for every 100
      seconds in PHP code

      Comment

      • Kimmo Laine

        #4
        Re: Is there any function in PHP like setTimeout with same functionallity in javascript

        <balakrishnan.d inesh@gmail.com wrote in message
        news:1168931303 .071685.241050@ 38g2000cwa.goog legroups.com...
        >
        Hi,
        >
        My exact problem is, i want to call a function for every 100
        seconds in PHP code

        either make a cronjob to call it every nth second or make an infinitely
        running daemon:
        <?php

        while(1){

        // Do the magik

        // Wait 100 seconds
        sleep(100);
        }

        ?>

        a cronjob might be easier for the server to handle

        --
        "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
        http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
        spam@outolempi. net | rot13(xvzzb@bhg byrzcv.arg)


        Comment

        • Pierre L.

          #5
          Re: Is there any function in PHP like setTimeout with same functionallity in javascript

          On Jan 16, 6:42 am, balakrishnan.di n...@gmail.com wrote:
          Is there any function in PHP like setTimeout with same
          functionallity in javascript ..
          Thing is, In php we have a function call settimeout for socket , But i
          need the same functionallity of settimeout( ) fucntion of javascript in
          PHP, Is that anything available in PHP. Is there plzzzzz reply me quick
          You may want to read further documentation about pcntl
          (especially pcntl_signal and pcntl_alarm).

          --
          Pierre

          Comment

          • P Pulkkinen

            #6
            Re: Is there any function in PHP like setTimeout with same functionallity in javascript

            either make a cronjob to call it every nth second or make an infinitely
            running daemon:
            <?php
            >
            while(1){
            >
            // Do the magik
            >
            // Wait 100 seconds
            sleep(100);
            }
            >
            ?>
            >
            a cronjob might be easier for the server to handle
            I would like to know more about this, because this daemon solution is really
            easy to do but is there some dangers with it:
            - max_execution_t ime in php.ini
            - is it causing stress to server.


            Comment

            • balakrishnan.dinesh@gmail.com

              #7
              Re: Is there any function in PHP like setTimeout with same functionallity in javascript

              hi Kimmo,

              Thanks for ur solution, But the problem with this solution is,
              After 100 seconds only , the page is getting displayed ,until nothing
              is displayed ..
              what I need is, while the counter is running in "sleep(100) " ,
              other process should be performed concurrently
              Is there any way for that

              Thank
              Dinesh...



              Kimmo Laine wrote:
              <balakrishnan.d inesh@gmail.com wrote in message
              news:1168931303 .071685.241050@ 38g2000cwa.goog legroups.com...

              Hi,

              My exact problem is, i want to call a function for every 100
              seconds in PHP code
              >
              >
              either make a cronjob to call it every nth second or make an infinitely
              running daemon:
              <?php
              >
              while(1){
              >
              // Do the magik
              >
              // Wait 100 seconds
              sleep(100);
              }
              >
              ?>
              >
              a cronjob might be easier for the server to handle
              >
              --
              "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
              http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
              spam@outolempi. net | rot13(xvzzb@bhg byrzcv.arg)

              Comment

              • Kimmo Laine

                #8
                Re: Is there any function in PHP like setTimeout with same functionallity in javascript

                "P Pulkkinen" <perttu.POISTAT AMA.pulkkinen@P OISTATAMA.elisa net.fiwrote in
                message news:be0rh.5262 $KW2.3297@reade r1.news.saunala hti.fi...
                >either make a cronjob to call it every nth second or make an infinitely
                >running daemon:
                ><?php
                >>
                >while(1){
                >>
                > // Do the magik
                >>
                > // Wait 100 seconds
                > sleep(100);
                >}
                >>
                >?>
                >>
                >a cronjob might be easier for the server to handle
                >
                I would like to know more about this, because this daemon solution is
                really easy to do but is there some dangers with it:
                - max_execution_t ime in php.ini
                set_time_limit( 0); should solve that, not sure thou.
                - is it causing stress to server.
                I don't know, haven't run any performance tests. Yet for some reason I'd
                rather use cron for scheduling rather than this sort of solution.
                --
                "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
                http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
                spam@outolempi. net | rot13(xvzzb@bhg byrzcv.arg)


                Comment

                • P Pulkkinen

                  #9
                  Re: Is there any function in PHP like setTimeout with same functionallity in javascript


                  <balakrishnan.d inesh@gmail.com kirjoitti
                  viestissä:11689 38556.076852.50 880@v45g2000cwv .googlegroups.c om...
                  "But the problem with this solution is,
                  After 100 seconds only , the page is getting displayed ,until nothing
                  is displayed ..
                  what I need is, while the counter is running in "sleep(100) " ,
                  other process should be performed concurrently
                  Is there any way for that"

                  I want to ask:
                  Is this desired effect related to certain page of current user rather than
                  to your entire web service?

                  Why, because nowadays ajax-kind of things are applied to get up-to-second
                  content etc. to client side. More simply put, for example very small or
                  invisible iframe can be updated every n-second, with the helps of meta
                  refresh tag. That update call can do something on the server and then
                  something as well in the client, since other frames and main frame can dig
                  iframe's content. Even I have not yet applied this, but I see the point
                  anyway. It would very much simulate the work of timeout.

                  I have an impression that cron thing refers more to need to update or backup
                  the whole server content. It is running there on the server by itself,
                  calling on timely basis some 'pages' invisibly. (Please anyone, feel free to
                  correct me...)



                  Comment

                  • C.

                    #10
                    Re: Is there any function in PHP like setTimeout with same functionallity in javascript

                    balakrishnan.di nesh@gmail.com wrote:
                    hi Kimmo,
                    >
                    Thanks for ur solution, But the problem with this solution is,
                    After 100 seconds only , the page is getting displayed ,until nothing
                    is displayed ..
                    what I need is, while the counter is running in "sleep(100) " ,
                    other process should be performed concurrently
                    Is there any way for that
                    >
                    Yes, but its not simple in PHP invoked from a webserver.

                    You've not really explained what you are trying to acheive.

                    Do you need a single thread of execution for the controlling process?
                    Must it be bound to a browser access? What are the failure modes? What
                    are the "other processes" to be performed concurrently? Should they
                    signal back to the browser? Should they run in a seperate process
                    group? Why does your script have to sleep while the other processes are
                    running? What have you tried?

                    C.

                    Comment

                    Working...