Use PHP Library/Extension in C#?

Discussion about the open-source Phalanger [?] project.

Use PHP Library/Extension in C#?

Postby noname0x100 » March 22nd, 2012, 1:15 pm

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#?

Postby Jakub Misek » March 22nd, 2012, 2:14 pm

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;
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Use PHP Library/Extension in C#?

Postby noname0x100 » March 22nd, 2012, 2:36 pm

Perfect! Thanks for the sample!!! :-)
noname0x100
 
Posts: 13
Joined: March 17th, 2012, 12:37 pm


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 29 guests

cron

User Control Panel

Login

Who is online

In total there are 29 users online :: 0 registered, 0 hidden and 29 guests (based on users active over the past 5 minutes)
Most users ever online was 511 on April 27th, 2024, 10:11 pm

Users browsing this forum: No registered users and 29 guests