views:

49

answers:

2

Apache server is installed in one machine and there is a .php script present in the server. Now from my win32 or c# application how do I invoke the script and how to receive the data from the server?

A: 

You need to open a network connection to localhost, or use the php command-line interpreter, but I'm not sure if that is linux-only, it should work for windows... try php (filename.php) to execute and return the echoed output.

CodeJoust
+1  A: 

Its the same as reading output from any web page, the php script is processed by the server

This code reads the output of a php page from the php.net online manual:

HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(@"http://www.php.net/manual/en/index.php");

using (HttpWebResponse resp = (HttpWebResponse) wr.GetResponse())
{
  StreamReader sr = new StreamReader(resp.GetResponseStream());
  string val = sr.ReadToEnd();
  Debug.WriteLine(val);
}
Matt
Hey, Thanks Matt..But We do have script located in server, how do i invoke..if i do like your method i can get the content, but i want to know how to execute a script in server.. how to do?
Shadow
As I understand it, the web server is configured to execute the script when clients request it, and the script can output content back to the client browser. PHP needs to be set up on the web server and the web server configured to recognise requests for .php files to be executed as scripts.
Matt
Matt..Thank u :-)
Shadow