# [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.

## 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 on other sites
include('test.php')

##### Share on other sites
Quote:
 Original post by conmanI'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

1. 1
Rutin
38
2. 2
3. 3
4. 4
5. 5

• 11
• 12
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
633350
• Total Posts
3011467
• ### Who's Online (See full list)

There are no registered users currently online

×