0

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?

2 Answers 2

2

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);
}
Sign up to request clarification or add additional context in comments.

4 Comments

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?
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.
what about input/argument ?
@Zakos again, its the same. If the page accepts query string parameters you can add them to the URL, if it accepts post data you can issue a post request and provide a request body.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.