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?

dtb
  • 213,145
  • 36
  • 401
  • 431
Jerodev
  • 32,252
  • 11
  • 87
  • 108
  • 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 – sll Sep 13 '11 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. – Jonathan Kuhn Sep 13 '11 at 20:12
  • Maybe you can use [Phalanger](http://www.php-compiler.net/) in some way? – Uwe Keim Sep 13 '11 at 20:13
  • use this http://www.csharp-station.com/HowTo/HttpWebFetch.aspx routine – Aaron Anodide Sep 13 '11 at 20:16

1 Answers1

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 )

Community
  • 1
  • 1
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179