Use PHP Library/Extension in C#?
3 posts
• Page 1 of 1
Use PHP Library/Extension in C#?
Hello, I'm looking for an example of PHP functions / classes from a file to use it?! I've only seen examples in order to use functions from C# to PHP. But it also goes the other way?
- noname0x100
- Posts: 13
- Joined: March 17th, 2012, 12:37 pm
Re: Use PHP Library/Extension in C#?
Hi,
The interoperability works in both ways. You can use .NET objects in PHP, and even PHP objects/functions/constants from C# or any other .NET language.
There are several samples and articles showing some possibilities of using PHP libraries in C#, like this one:
- http://www.php-compiler.net/blog/2012/n ... langer-3-0
There is Sample at the bottom of the page showing both interoperability ways.
Simply try to call
PHP.Core.ScriptContext.CurrentContext.Include( ... )
to include PHP script into C# context.
Then you have access to all the functions/classes/constant in included PHP scripts by using object
dynamic globals = PHP.Core.ScriptContext.CurrentContext.Globals;
The interoperability works in both ways. You can use .NET objects in PHP, and even PHP objects/functions/constants from C# or any other .NET language.
There are several samples and articles showing some possibilities of using PHP libraries in C#, like this one:
- http://www.php-compiler.net/blog/2012/n ... langer-3-0
There is Sample at the bottom of the page showing both interoperability ways.
Simply try to call
PHP.Core.ScriptContext.CurrentContext.Include( ... )
to include PHP script into C# context.
Then you have access to all the functions/classes/constant in included PHP scripts by using object
dynamic globals = PHP.Core.ScriptContext.CurrentContext.Globals;
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: Use PHP Library/Extension in C#?
Perfect! Thanks for the sample!!!
- noname0x100
- Posts: 13
- Joined: March 17th, 2012, 12:37 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 29 guests