Forum Moderators: coopster

Message Too Old, No Replies

include (); simultaniously.

Multiple includes simultaniously. Is that possible?

         

ikbenhet1

10:42 pm on Mar 24, 2004 (gmt 0)

10+ Year Member




first $a includes, after $a is finished $b includes.

include($a);
include($b);

Is there a way to include simultaniously,so that include($b) will fire off at the same moment as include ($a)?

jatar_k

10:47 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



no they don't work that way

the parser reads line by line, it can't do 2 things at once

What exactly are you trying to do? I don't see the need myself.

ikbenhet1

10:50 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



it for a meta search.

include (a) gets results from search engine x
include (b) gets results from search engine y

they insert in the same mysql table afterwards i select from it

but it sometimes takes up 3 to 5 seconds

vincevincevince

10:58 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sure...

write your include files
write shell scripts to call them
make the include files output results to data / a file
then use passthru() to run the shell scripts

this will enable you to start them all running together, and you'll just have to read the file / database and get the results from all of them

ikbenhet1

10:36 am on Mar 25, 2004 (gmt 0)

10+ Year Member




Thanks for that.

What makes it go simulatiously?
Would the following be executed simultaniously?

$x=passtru("curl x");
$y=passtru("curl y");

does it only go simultanious if it's a shell script?

vincevincevince

6:00 pm on Mar 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



passthru() will allow simultaneous executions of external scripts... as long as the output of that program is redirected to a file or some other output stream.

see [uk2.php.net...]

it's one easy way to get what you want to do done

you don't need to use shell scripts, you can instead call it as:
/usr/local/bin/php /path/to/script.php

otherwise, consider simple forking

[phpfreaks.com...]

the most effective way however is using pcntl_fork

ikbenhet1

7:53 pm on Mar 25, 2004 (gmt 0)

10+ Year Member




thanks!

exec("command >/dev/null &");

that command forks too. very easy.