可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Sorry if this is a silly and/or stupid question but... Will there ever be, or would it even be possible to have a PHP.NET? Or have I got the wrong end of the stick?
It seemed to me that one of the main points of .NET was that you could write your code in one of a bunch of the .NET languages and have it compile into CLR. Could this happen with PHP, or is there something about PHP that makes this impossible? Or is there more political reasons? Or is it just a retarded idea?
回答1:
As an aside:
I don't believe .Net support for PHP would be a great idea.
I use PHP every day of my life. It's not because I like the language (it's a collection of mismatched functions with very little OO support), but rather because it's the best tool for the job.
PHP has a lightweight feel and one can do almost anything in a few easy lines. It's string handling is effortless, and support is ubiquitous. Array handling is great, too.
I feel that if PHP joined the .Net CLR I would not be tempted to switch over to use it. If one wanted to work with .Net one would do better to use a nicer, better structured language, such as C#.
回答2:
Someone has actually already begun working on just such a thing
http://www.codeplex.com/Phalanger
http://www.php-compiler.net/doku.php
回答3:
I would say that it is unlikely as that there is ASP.net, but I would not say never because of Python.NET or IronPython. There is already one attempt called Phalanger. From the looks of the official wiki, its a serious development effort.
回答4:
Actually it exists. It's not called PHP.NET, but Phalanger(http://phalanger.codeplex.com). It compiles PHP code into MSIL instructions.
It allows to run PHP application in so called legacy mode (and you can benefit from a faster running time since it's compiled), and if you want to use CLR features that are not present in PHP you can turn on PHP/CLR compiler extensions.
There is also so called Pure mode where PHP langauge is modified to behave more like C# or Visual Basic.
I think combining PHP and .NET is great idea, since you can make the best of both worlds. From PHP it would fast development and deployment process, steep learning curve and there are lots of great PHP open-source applications. On the .NET side, verifiable ISO standartized environment, peformance, managed secure code, advanced development tools,...
回答5:
Sure, there's a possibility. Python runs in the CLR, after all.
Side note: PHP is now a one-click install for IIS, so if you're waiting to bring PHP into your Microsoft stack, go ahead and give it a try. MS is even working on a PHP bytecode cache for Windows.
回答6:
Once this is in I don't see why not.
http://en.wikipedia.org/wiki/Dynamic_Language_Runtime
回答7:
The CLR is essentially a virtual machine, so things are compiled to it essentially the same way C code is compiled to x86 or PowerPC or arm or whatever.
There is an implementation of python that compiles to .NET assemblies, there's also COBOL, and a few others. No technical reason PHP couldn't be done the same and executed by the CLR in IIS.
回答8:
.NET is a framework that is based on a number of technologies such as CLR and provides an extensive collection well-organized class libraries that are suitable for almost all conceivable functions that are used in Web applications. In addition, it allows you to easily create components that extend the framework.
Although PHP has similar properties, such as PEAR libraries, PHP and ASP.NET are not really identical, because the .NET framework ab ovo on an OOP paradigm and OOP-based approaches, and PHP is not. This difference is most evident in the way, is how to access classes and objects in PHP and ASP.NET.
回答9:
You could give a try to the jsc project which will convert MSIL to php source for you.
This will enable you to write C# code in visual studio and run it on an inexpensive php server.
alt text http://jsc.sourceforge.net/examples/avalon/assets/AvalonExampleGallery/Preview.png
回答10:
The two are totally different, they are in competition with each other. Both will try to be good at their ends. So i dont think there is going to be anything as such in the future. However, you can use PHP inside of Visual Studio, there are plugins available for that.
Thanks
回答11:
PHP have got suspiciously pally with Windows... it doesn't seem impossible
And besides PHP.NET
回答12:
Well PHP is good as is already. Even if it does become PHP.NET I doubt it will be done by Microsoft.
回答13:
you could develop php on windows to use windows functions, and ultimately call on .NET objects. I believe apache now allows php to call on native windows calls/functions and .NET functions/classes/objects, provided you have the right settings turned on.
as for .NET adapting php syntax, i think some people are trying to do this, aside from the existing attempts.