Help - Search - Members - Calendar
Full Version: How to run more than one PHP script SIMULTANEOUS
Weborum Webmaster Forum > Web Page Design > PHP
pzh
Hello friends !
How can I run more than one PHP script SIMULTANEOUS
leo
welcome to weborum pzh smile.gif

could you give us a little more information please, like what two scripts you would like to run at the same time smile.gif
Erikina
You can run php code from a string with

eval($string);
Timo
Can you explain what you're trying to do?
I don't believe you could operate two scripts at the same time because things are done in a linear manner, I believe... But you could combine the two scripts to give the effect that they are running at the same time.

I could be wrong about this, however, since I've never really looked it up. But it would be interesting if you could. ;D

I've never used eval but it seems to allow a delay in the execution of code. Running the code from the eval... wouldn't this just cause one script to start while in the other? And then it would return to the original? They technically would only be merged with the code you evaled in the center and not running at the same time like he wants, I think.
Correct me if I'm wrong, I've never used that function. Interesting info though, looking forward to this topic.
aviansuicide
To run two scripts in EXACT sync you'd have to fork php...and no..php doesn't support forking.
Erikina
QUOTE(Timo @ Mar 25 2005, 01:58 PM)
I've never used eval but it seems to allow a delay in the execution of code. Running the code from the eval... wouldn't this just cause one script to start while in the other? And then it would return to the original? They technically would only be merged with the code you evaled in the center and not running at the same time like he wants, I think.
Correct me if I'm wrong, I've never used that function. Interesting info though, looking forward to this topic.
[right][snapback]25195[/snapback][/right]


I'm not sure what you mean, but I don't see how you can use eval() for delays?

For instance, try this php code:

PHP

<?php
$delay
= 'sleep(2); echo(\'This is from the delay<br />&#092;');';

echo('This is the first echo <br />');

eval(
$delay);

echo(
'This is from the last echo');
?>



For some reason my "\" is being replaced with "&#092 ;"
Timo
QUOTE
Among other things, this can be useful for storing code in a database text field for later execution.

http://us2.php.net/manual/en/function.eval.php

When I said delay I didn't mean to imply you to use a sleep function... I mean what it says in the description... I was reflecting on php.net's manual's information...

Either way, I don't see how it could help his specific problem... How would it help his problem was what I was wondering.

(edit: I also don't have access to an FTP server w/ PHP right now (library) so I can't test it to see what it does and only have a vague idea of what its purpose is so mind my ignorance of the issue.)
Erikina
QUOTE(Timo @ Mar 25 2005, 03:01 PM)
QUOTE
Among other things, this can be useful for storing code in a database text field for later execution.

http://us2.php.net/manual/en/function.eval.php

When I said delay I didn't mean to imply you to use a sleep function... I mean what it says in the description... I was reflecting on php.net's manual's information...

Either way, I don't see how it could help his specific problem... How would it help his problem was what I was wondering.

(edit: I also don't have access to an FTP server w/ PHP right now (library) so I can't test it to see what it does and only have a vague idea of what its purpose is so mind my ignorance of the issue.)
[right][snapback]25202[/snapback][/right]


I see what you mean now. By delay, you meant as in storing in a database. Sorry, I misunderstood you.

I'm not sure if this helped his problem or not, he could want to execute some php code. He might want to know how to use an iframe to put a php page in a php page. He might want to include a php page from a php page, which would mean they both would run at the same time. I have no idea, I was just tossing up a possible solution.

As for what happens, the sleep() delays everything (because it's still one script).
Timo
Ahh I see. Thanks for the info... Yeah, it was just confusion on both sides haha...

Hmm since, as aviansuicide pointed out, PHP can't handle two scripts running at the same time I suggest merging them if you want to create the illusion of them being run at a similar time... What are the functions of the scripts? Something easy to run next to each other if placed in the same script? Or do they have a lot of loops with specific timers?

Cause you could just turn 2 scripts into 1 and have them execute code and display output in a way such that they seem to be running at the same time. I don't see the point in running two scripts at the same time, however, since this is all run server side. The output would be the same, right?

Is this an efficiency issue? Or is it some sort of other issue?

-Tim
pzh
Thanks to all my friends . biggrin.gif
aviansuicide
QUOTE(pzh @ Mar 25 2005, 06:35 AM)
Thanks to all my friends . biggrin.gif
[right][snapback]25207[/snapback][/right]


Care to tell us exactly what you were trying to do, then?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.