First of all, the answer is yes - It is absolutely possible.
[First] Two program running modes, command line program and form program:
In the PHP installation program directory, there is a PHP. exe, the program can run independently and parse PHP code. (Recommended learning: PHP programming from entry to proficiency)
With the support of this application, PHP code can run like a .net program with the support of PHP.exe , the official introduction says: "PHP's command line mode enables PHP scripts to run completely independently of the web server."
Let’s talk about form applications, PHP has an extension that facilitates the development of Windows forms. The extension is called WinBinder. WinBinder encapsulates a large number of Windows APIs. , you can easily use PHP to develop Windows Forms programs as long as you call it.
WinBinder is just an extension, small in size, light in weight, and fast to run. However, because it seems to be an individual-led development, there are many shortcomings at present;
In addition to the PHP desktop application In addition to using the above extensions, PHP also has a sub-project called PHP-GTK, which is also dedicated to using PHP to develop desktop applications. It is directly affiliated with the official government. However, due to unknown reasons, as of 2008, there are no new projects. version appears, but it is more mature and stable than WinBinder.
[Second] Compare it with languages that are conventionally considered capable of developing desktop programs:
Languages like C# and Java, In fact, they all have background service support like php.exe to be able to execute their programs in this environment. For example, if you develop a form application based on .net 4.0, if you want to run it, you must install .net 4.0 support.
At the same time, .net supports form development. There are a large number of form controls that have been developed in advance by language providers for you to choose from. You don’t have to develop them yourself. You can use them directly by just calling them. .
After PHP loads the WinBinder module, its principle is basically the same as the above situation.
[Third] The prospects of developing desktop applications with PHP
The development of desktop programs with PHP is relatively niche, so PHP is widely used in desktop application development It appears to be weak.
The prospects are far inferior to programs such as C#, but for PHP programmers, it is perfectly fine to provide this kind of desktop application for their own use, or as a program used by some units to develop independent software and special functions. of.
The above is the detailed content of Can php write desktop software?. For more information, please follow other related articles on the PHP Chinese website!