Jump to content
  • Advertisement
Sign in to follow this  
conman

[web] process php file from a php script

This topic is 4850 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'd like to process another php file from a php script. My first solution goes like this:
$cmd = "C:\\...\\apachefriends\\xampp\\php\\php.exe -f test.php";
exec($cmd, $out);

for ($i=0; $i<count($out); $i++)
  echo $out[$i];
But I have some problems with this solution: I need to know where the php.exe is located on the server. Is there some kind of global variable containing this path? When the exec() command is executed a terminal popps open and closes again. Because I have a apache-server on my system I'd like to know if the window will be seen at the server side or at the client side? Is this a good/elegant solution at all? because the exec() command will be called every time a user navigates on my site. So every time a window will popp open on the server/client side! Is ther a better way to do this?? Thanks in advance!! Constantin

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by conman
I'd like to process another php file from a php script. My first solution goes like this:

(used exec)

But I have some problems with this solution:
I need to know where the php.exe is located on the server. Is there some kind of global variable containing this path?


Having a standalone PHP binary on a PHP web server is not mandatory, therefore there is no way to determine its path.

Quote:

When the exec() command is executed a terminal popps open and closes again. Because I have a apache-server on my system I'd like to know if the window will be seen at the server side or at the client side?


Server-side, definitely.

Quote:

Is this a good/elegant solution at all?


Not particularly. Using require() (which is similar to include) is a better bet, unless you really need to do something unusual.

Quote:

because the exec() command will be called every time a user navigates on my site. So every time a window will popp open on the server/client side!


The window only "pops up" if the server is running an operating system which runs the service as a desktop application; this won't normally be the case.

Specifically, this will never happen on Linux / Unix based servers, and only happen on Windows if it's being run interactively rather than as a service (which is the normal way).

Quote:

Is ther a better way to do this??


Use require() if possible.

Mark

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!