开发者

How do I invoke a PHP script on a Web server?

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 receiv开发者_Go百科e the data from the server?


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);
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜