开发者

Call .net function from PHP page

I have this function in .net code:

public class StringGenerator
{
    public static string Generate开发者_如何学JAVAString(string hash)
    {
        return hash.GetHashCode();
    }
}

I want to be able to call this from PHP page. Any idea how?

Edit: looking in php documentation, http://www.php.net/manual/en/class.dotnet.php, I see that it possible. but I can't code the code to find this dll, even with strongly named dll. the dll file is in the same folder as the php page.


If you're on Windows, this article might help:

PHP and .NET

On another platform you could possibly use something like Phalanger to get access to the .NET runtime through PHP.


There are several ways to include .NET DLLs in your PHP installation (already well-documented), most of which are quite complicated and tend to be more trouble than they're worth as you lock yourself into running IIS as your webserver.

The best solution is to write web services which you can deploy on an IIS server. This frees you from having .NET dependencies in your PHP code, making it infinitely easier to migrate your application to another environment should the need ever arise. Creating web services in Visual Studio is a breeze - just start a new web service project, drop in your DLLs and VS automatically generates a WSDL that you can hit with PHP's SOAP functionality.

I was in this same situation last year and I explored both options - web services were definitely the better and more flexible option.


  • Mono
  • Windows Azure and Web Services
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜