I'm using a C#.NET DLL with ASP.NET 2.0 and it's working now. I want to use the same DLL in PHP.
I'm a newbie in PHP; would someone please tell me how to use it in PHP or could you share some example?
PHP has a built-in Windows-only extension called DOTNET that allows you to use .NET libraries in a PHP application.
Note that you'll need to make sure your assemblies are declared as COM visible:
[assembly: ComVisible(true)]
Here are two examples.
<?php
$stack = new DOTNET("mscorlib", "System.Collections.Stack");
$stack->Push(".Net");
$stack->Push("Hello ");
echo $stack->Pop() . $stack->Pop();
?>
Another example demonstrating functionality of DOTNET class:
<?php
$full_assembly_string = 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a8425bc35256e463';
$full_class_name = 'System.Windows.Forms.Form';
$form = new DOTNET($full_assembly_string, $full_class_name);
// code to add buttons, menus, text, etc
$form->Show();
$form_event = '';
while($form_event !== 'close') {
// handle form functions and events
}
?>
you are using the PHP Version 5.4.7 you should already have com_dotnet.dll if you dont have it you can download it on "download" and add to your ext/ path inside php directory.
Edit you php.ini file
extension=php_com_dotnet.dll
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With