Jezza Posted December 2, 2009 Share Posted December 2, 2009 Is there any possible, known, way to execute a PHP page like a process, so it doesn't display it but it runs it and does all the commands? I'm making a register page and when the person registers it will send him an email and say "your email has been sent" but i don't want to wait for it to send the email so i was going to create another page which does that and execute that one, whilst displaying the "email sent" message. Quote Link to comment https://forums.phpfreaks.com/topic/183686-execute-a-php-page/ Share on other sites More sharing options...
monkeytooth Posted December 2, 2009 Share Posted December 2, 2009 include() include_once() require() require_once() embed the "Hidden" commands within the file thats your working with... Quote Link to comment https://forums.phpfreaks.com/topic/183686-execute-a-php-page/#findComment-969530 Share on other sites More sharing options...
mikesta707 Posted December 2, 2009 Share Posted December 2, 2009 in addition to include() and its derivatives, you cold use get_file_contents() and use eval, but its basically the same thing Quote Link to comment https://forums.phpfreaks.com/topic/183686-execute-a-php-page/#findComment-969535 Share on other sites More sharing options...
Jezza Posted December 2, 2009 Author Share Posted December 2, 2009 But then it waits for output, I don't want it to wait for output, I want it to run as a process. Quote Link to comment https://forums.phpfreaks.com/topic/183686-execute-a-php-page/#findComment-969538 Share on other sites More sharing options...
trq Posted December 2, 2009 Share Posted December 2, 2009 But then it waits for output, I don't want it to wait for output, I want it to run as a process. Waits? An email should take far less than a second to be sent. PHP has no forking capabilities, the best you could attempt would be to execute a command line script in the background using exec but Iv'e not seen to many people have success with this method. Quote Link to comment https://forums.phpfreaks.com/topic/183686-execute-a-php-page/#findComment-969555 Share on other sites More sharing options...
Jezza Posted December 2, 2009 Author Share Posted December 2, 2009 But then it waits for output, I don't want it to wait for output, I want it to run as a process. Waits? An email should take far less than a second to be sent. PHP has no forking capabilities, the best you could attempt would be to execute a command line script in the background using exec but Iv'e not seen to many people have success with this method. Well i really just want to know for future reference i know a list of call things i can do with it, such as make a program (non-PHP) that updates a website eveyr 24 hours using a php script etc. Your saying that i can exec something? What is it that i can try to execute? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/183686-execute-a-php-page/#findComment-969556 Share on other sites More sharing options...
trq Posted December 2, 2009 Share Posted December 2, 2009 I linked you to the exec group of function in my last reply. They allow you to execute external programs such as php's command line interface. eg; exec('/usr/bin/php somescript.php &'); Quote Link to comment https://forums.phpfreaks.com/topic/183686-execute-a-php-page/#findComment-969558 Share on other sites More sharing options...
Jezza Posted December 2, 2009 Author Share Posted December 2, 2009 Aaah perfect, it works great! That's what i was looking for, the program which executes php scripts in a process, thank you very much. I used "C:\xampp\php\php C:\site\tutorials\mail.php" and i recieved an email from myself so it worked very well hehe. Quote Link to comment https://forums.phpfreaks.com/topic/183686-execute-a-php-page/#findComment-969561 Share on other sites More sharing options...
trq Posted December 2, 2009 Share Posted December 2, 2009 Aaah perfect, it works great! That's what i was looking for, the program which executes php scripts in a process, thank you very much. I used "C:\xampp\php\php C:\site\tutorials\mail.php" and i recieved an email from myself so it worked very well hehe. Still, exec has to wait for the execution to finish unless you put the script into the background. No idea how to do it on windows, but in bash you use & after the command in question. It may even be the same on windows. Quote Link to comment https://forums.phpfreaks.com/topic/183686-execute-a-php-page/#findComment-969569 Share on other sites More sharing options...
Jezza Posted December 2, 2009 Author Share Posted December 2, 2009 Still, exec has to wait for the execution to finish unless you put the script into the background. No idea how to do it on windows, but in bash you use & after the command in question. It may even be the same on windows. I have this: pclose(popen("start $command","r")); hehe Quote Link to comment https://forums.phpfreaks.com/topic/183686-execute-a-php-page/#findComment-969580 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.