PHP - Shoot another script inside a script without abort the current [closed]

1

I have a PHP script in which I need to " simply fire " another script though, without losing the flow of the current script.

Example:

<?php
// um comando
// outro comando
//*** Aqui preciso, por exemplo, disparar o script: teste.php

// outro comando
// outro comando
// outro comando
//*** Aqui preciso novamente disparar o script: teste.php

// outro comando
// outro comando
// outro comando
// outro comando
// fim

(OBS: Servidor compartilhado Locaweb)
?>
    
asked by anonymous 05.06.2016 / 00:59

1 answer

1

If you are running this script in CGI mode (* locaweb only allows you to run these methods in CGI mode), you can use the php exec function

I did not find anything in the locaweb about the exec function, but I found out about the shell_exec function that is used to execute commands in the shell:

link

I do not know exactly what you want to do but it's worth a caveat if your idea is to perform parallel processing.

PHP supports threads, so if your idea is this take a look at the doc:

link

Another option if this runs on the command line and is synchronous, you can subdivide this script into smaller script and use pipe redirection:

ex: script1.php, script2.php, script3.php

It would run on the command line something like this here:

php script1.php | php script2.php | php script3.php

I hope I have helped.

    
05.06.2016 / 02:06