Skip to main content
GameDev.net gamedev.net
🔒 Locked 🤖 Godot

[web] process php file from a php script

Started by conman Aug 6, 2005 at 11:08 AM 1 replies 1k views
Original Post
conman
conman
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
markr
markr
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.