Page 1 of 1
Running PHP function in background
Posted: Sun Feb 21, 2010 3:33 pm
by Martinsos
I made a function SendNewsletter($newsletterID) that i want to run in background of another script, which means that the parent script wont have to wait for the function to execute before it can continuo with its own execution. I have read about exec() function in php, but i dont understand how can i use it to run a php function (I also need to pass an argument to it). Can smb pls help me? Thank you in advance
Re: Running PHP function in background
Posted: Sun Feb 21, 2010 6:50 pm
by manohoo
PHP code is executed sequentially, you can't run 2 code blocks in parallel... that's what I understand by what you call "background"
Just call the function whenever needed.
Re: Running PHP function in background
Posted: Sun Feb 21, 2010 8:52 pm
by Griven
I haven't delved into it myself, so I'm not going to try writing up an explanation.
However, if you go to Google and look up "asynchronous PHP", you should find what you're looking for.
Re: Running PHP function in background
Posted: Sun Feb 21, 2010 10:21 pm
by mikosiko
manohoo wrote:PHP code is executed sequentially, you can't run 2 code blocks in parallel... that's what I understand by what you call "background"
Just call the function whenever needed.
Pshh...

seems than you can
http://phplens.com/phpeverywhere/?q=node/view/254
or
http://phplens.com/phpeverywhere/?q=node/view/255
and look also popen I haven't implemented nothing in this line.. but I'll do some test.
Miko