Running PHP function in background

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Martinsos
Forum Newbie
Posts: 1
Joined: Sun Feb 21, 2010 3:27 pm

Running PHP function in background

Post 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
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: Running PHP function in background

Post 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.
Griven
Forum Contributor
Posts: 165
Joined: Sat May 09, 2009 8:23 pm

Re: Running PHP function in background

Post 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.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Running PHP function in background

Post 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... :wink: seems than you can :arrow: http://phplens.com/phpeverywhere/?q=node/view/254

or :arrow: 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
Post Reply