1

I was wondering if it is possible to get the HTML output of a PHP file using a C# Windows application. I have already googled for this, but all I could find was a compiler where you could use PHP together with C#.

Is there any possibility to do this?

4
  • 2
    If you mean local php script then you can execute php.exe passing as command line arg script file name, .net provides features to execute external applications as start process Commented Sep 13, 2011 at 20:11
  • do you mean get the html out of a php source file or have php evaluate the php file and get the resulting html? You might have problems with the latter simply because of plugins/external (e.g. db) connections. Commented Sep 13, 2011 at 20:12
  • Maybe you can use Phalanger in some way? Commented Sep 13, 2011 at 20:13
  • use this csharp-station.com/HowTo/HttpWebFetch.aspx routine Commented Sep 13, 2011 at 20:16

1 Answer 1

1

You can use HttpWebRequest - http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx to get the HTML.

As everyone is suggesting to get output of local script: look into System.Diagnostics.Process.Start and related functions to run from command line. You can either dump output to file first and than read it with C# or redirect output (i.e. C# - Realtime console output redirection )

Sign up to request clarification or add additional context in comments.

3 Comments

Yes, but I would like to get the output of a local php file.
Then you will need to run the script yourself using the interpreter, @Jerodev
if that's the case, your option with C# is simulate how you would do it from the command line - i.e. launch a process that is the php compiler.

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.