Closed taotao2014 closed 9 years ago
hi,
There are few limitations when using this old API (context.Call). You have to 'wrap' Student into ClrObject first, so phalanger will be able to use it properly.
Use following call instead, so all this stuff is performed automatically
dynamic php = context.Globals; // dynamic context used to call functions, instantiate classes etc..
Student student = php.myTest(new WebClient(), new Student() { Age = 20, UserName = "David" });
for more info about dynamic context see Globals at http://www.php-compiler.net/blog/2012/net-interoperability-overview-of-phalanger-3-0
New, old model, have been resolved, thank you very much.
=====c# code:======
static void Main(string[] args) { ScriptContext context = ScriptContext.CurrentContext; context.Output = Console.Out; context.Include(@"C:\script.php", true); PhpReference r = context.Call("myTest", new WebClient(), new Student() { Age = 20, UserName = "David" }); Console.WriteLine(r.Value); Console.ReadLine();
}
=====script file:=====
<? use System\Net; use CSharpApp;
?>