Home >Backend Development >PHP Tutorial >PHP calls the dll class library method developed by C#, _PHP tutorial
Sometimes, we need to use dll libraries written in other languages in php, such as dlls written in C#. The method is to use the PHP new COM method to call. Before calling, the dll library must be registered and the program Set into the global cache.
1. Create a C# Class Library and name it: HelloWorld
2. Open the properties of the project , click "Application" on the left (the first tab), and then click the Assembly Information button. In the pop-up Dialog, you must check the bottom box: Make assembly COM -visible! Otherwise, this dll will not be accessible in COM mode. (You can also write [ComVisible(true)] in the class declaration in the code, the effect is the same, you need to add using System.Runtime.InteropServices; reference)
3. Create a strongly named signature file and use
Use vs.net’s “Vsitual Studio .Net Tool” -->Vistual Studio .Net command prompt, enter sn -k d:HelloWorld.snk and press Enter to create a strong named signature file
Open the properties of the project, click Signing on the left and check Sign the assembly. Select
4. Create a class library and compile it into a dll
Copy code
PHP test:
Copy code
How to call C language program in php?
PHP can be done with two or three lines of code. Are you sure that your C language can publish webservices and generate standard soap files? If you think that PHP is written in C language and can simply call each other, then you are wrong. Yes, the idea is good. I want to combine the advantages of each. In addition, PHP cannot satisfy your calculation. Are you sure?