I'm working on an open source PHP project for websites, and once I release version 1.0, I want to provide the same product for websites using the IIS/ASP.NET platform.
我正在为网站开发一个开源PHP项目,一旦我发布1.0版,我想为使用IIS / ASP.NET平台的网站提供相同的产品。
When the time comes I'll go ahead and learn ASP.NET to do the translation, but it would be helpful for me to know already if there are any fundamental conceptual or architectural differences between the two platforms. I want to bear these in mind while building the PHP, to enable the two code bases to look as similar as possible, even though there will be of course be many differences in syntax and library function names.
到时候我会继续学习ASP.NET来进行翻译,但如果两个平台之间存在任何基本的概念或架构差异,那将对我们有所帮助。我想在构建PHP时牢记这些,以使两个代码库看起来尽可能相似,即使语法和库函数名称当然会有很多差异。
I thinking of things like variable/array types, constant definitions, function namespaces, HTTP form and header handling. Anything that will make it difficult to look at the two code bases side-by-side, and see a direct correlation between each line of code.
我想到了变量/数组类型,常量定义,函数名称空间,HTTP表单和标题处理等内容。任何使得难以并排查看这两个代码库的东西,并看到每行代码之间的直接相关性。
My PHP is backwards compatible to 4.x, so I'm not using exception handling or objects.
我的PHP向后兼容4.x,所以我没有使用异常处理或对象。
Are there any good articles or point-by-points about this online?
关于这个在线是否有任何好文章或逐点?
4 个解决方案
#1
1
Depending on which version of ASP.NET you are using, between PHP5 and .NET 3.5 there are incredible differences.
根据您使用的ASP.NET版本,在PHP5和.NET 3.5之间存在令人难以置信的差异。
First, you will need to learn a .net language.
首先,您需要学习.net语言。
the .NET framework will take a lot of the work out of creating some interactive components, so people may expect that you are taking advantage of these, so the pages will either appear different, or you will need to do more work to get the php one to look like the asp.net.
.NET框架将需要大量的工作来创建一些交互式组件,所以人们可能会期望你正在利用这些,所以页面将显示不同,或者你需要做更多的工作来获得PHP一个看起来像asp.net。
I think the expectations of people will be the biggest hurdle in such an endeavor, and I agree with Matt Lacey that if there is a way to have it done for you you may just want to start with that, but, you will want to learn C# or VB.NET (I would suggest the former) and do the translation yourself, to better meet the expectations of your users.
我认为人们的期望将成为这种努力的最大障碍,我同意Matt Lacey的说法,如果有办法让你完成它,你可能只想从那开始,但是,你会想要学习C#或VB.NET(我建议前者)并自己做翻译,以更好地满足用户的期望。
Another big difference is that .NET provides several ways to create webservices, so you will need to decide which is best for your product when you write it.
另一个很大的区别是.NET提供了几种创建Web服务的方法,因此您需要在编写时确定哪种方法最适合您的产品。
But, if you have a good separation between the business logic and view part of your application then the design of the view shouldn't change too much.
但是,如果您在业务逻辑和应用程序的视图部分之间有一个很好的分离,那么视图的设计不应该改变太多。
#2
1
The differences bewteen PHP and classic ASP are relatively small, small enough that some mechanical translation is possible. take a look at asp2php which proves it can be done in the ASP to PHP direction.
PHP和经典ASP之间的差异相对较小,足够小,可以进行一些机械翻译。看看asp2php,证明它可以在ASP到PHP的方向上完成。
However in the body of your question you mention asp.net. Typically ASP.NET uses a framework called webforms which is designed to make programming web applications much more like programming desktop applications. This is very different from the inline code favoured by raw PHP and in order to take advantage of ASP.NET you will have to pretty much abandon your php code and use the application only as a functional example of how the .NET port should work. I have heard that it is possible to write much more scripty style ASP.NET that writes the response directly but i have no experience of doing this and you will find support for it very minimal indeed.
但是在你的问题正文中你提到了asp.net。通常,ASP.NET使用一个名为webforms的框架,该框架旨在使编程Web应用程序更像编程桌面应用程序。这与原始PHP所支持的内联代码非常不同,为了利用ASP.NET,您将不得不放弃您的PHP代码,并仅将该应用程序用作.NET端口应如何工作的功能示例。我听说有可能编写更多脚本风格的ASP.NET直接编写响应,但我没有这样做的经验,你会发现它的支持非常小。
In short: Porting raw PHP to classic ASP should be easy. Both are scripting languages which give raw access to various HTTP variables and parameters and allow the programmer to write directly to the response. If you are using a framework on the PHP or the ASP side, as you will be expected to if you use ASP.NET then things will be very different.
简而言之:将原始PHP移植到经典ASP应该很容易。两者都是脚本语言,它们提供对各种HTTP变量和参数的原始访问,并允许程序员直接写入响应。如果您在PHP或ASP端使用框架,那么如果您使用ASP.NET,那么事情将会非常不同。
#3
1
Just to get it off my chest: Why convert it at all? Running the same codebase on an IIS/PHP stack should be fairly easy.
只是为了让它脱离我的胸膛:为什么要转换它?在IIS / PHP堆栈上运行相同的代码库应该相当容易。
Having said that, take a look at the PHP to ASP.NET Migration Assistant tool Microsoft provides.
话虽如此,请看一下Microsoft提供的PHP to ASP.NET Migration Assistant工具。
The page also provides a list of items that can be converted (well, mostly anyway):
该页面还提供了可以转换的项目列表(好吧,无论如何):
- Language migration
- Built-in functions support
- Include files
- ...
内置功能支持
As well as items that can't be converted (items you'll have to completely re-write):
除了无法转换的项目(您必须完全重写的项目):
- Dynamic includes
- Declare statement
- PHP functions not completed in current script.
- ...
PHP函数未在当前脚本中完成。
#4
0
Rather than try and do the translation to a language (and stack?) you're not familiar with I'd recommend looking at something like http://www.hawhaw.de/ to do the conversion/translation for you.
你不是很熟悉,而是试图翻译成一种语言(和堆栈?),我建议你去http://www.hawhaw.de/查看为你做转换/翻译的事情。
#1
1
Depending on which version of ASP.NET you are using, between PHP5 and .NET 3.5 there are incredible differences.
根据您使用的ASP.NET版本,在PHP5和.NET 3.5之间存在令人难以置信的差异。
First, you will need to learn a .net language.
首先,您需要学习.net语言。
the .NET framework will take a lot of the work out of creating some interactive components, so people may expect that you are taking advantage of these, so the pages will either appear different, or you will need to do more work to get the php one to look like the asp.net.
.NET框架将需要大量的工作来创建一些交互式组件,所以人们可能会期望你正在利用这些,所以页面将显示不同,或者你需要做更多的工作来获得PHP一个看起来像asp.net。
I think the expectations of people will be the biggest hurdle in such an endeavor, and I agree with Matt Lacey that if there is a way to have it done for you you may just want to start with that, but, you will want to learn C# or VB.NET (I would suggest the former) and do the translation yourself, to better meet the expectations of your users.
我认为人们的期望将成为这种努力的最大障碍,我同意Matt Lacey的说法,如果有办法让你完成它,你可能只想从那开始,但是,你会想要学习C#或VB.NET(我建议前者)并自己做翻译,以更好地满足用户的期望。
Another big difference is that .NET provides several ways to create webservices, so you will need to decide which is best for your product when you write it.
另一个很大的区别是.NET提供了几种创建Web服务的方法,因此您需要在编写时确定哪种方法最适合您的产品。
But, if you have a good separation between the business logic and view part of your application then the design of the view shouldn't change too much.
但是,如果您在业务逻辑和应用程序的视图部分之间有一个很好的分离,那么视图的设计不应该改变太多。
#2
1
The differences bewteen PHP and classic ASP are relatively small, small enough that some mechanical translation is possible. take a look at asp2php which proves it can be done in the ASP to PHP direction.
PHP和经典ASP之间的差异相对较小,足够小,可以进行一些机械翻译。看看asp2php,证明它可以在ASP到PHP的方向上完成。
However in the body of your question you mention asp.net. Typically ASP.NET uses a framework called webforms which is designed to make programming web applications much more like programming desktop applications. This is very different from the inline code favoured by raw PHP and in order to take advantage of ASP.NET you will have to pretty much abandon your php code and use the application only as a functional example of how the .NET port should work. I have heard that it is possible to write much more scripty style ASP.NET that writes the response directly but i have no experience of doing this and you will find support for it very minimal indeed.
但是在你的问题正文中你提到了asp.net。通常,ASP.NET使用一个名为webforms的框架,该框架旨在使编程Web应用程序更像编程桌面应用程序。这与原始PHP所支持的内联代码非常不同,为了利用ASP.NET,您将不得不放弃您的PHP代码,并仅将该应用程序用作.NET端口应如何工作的功能示例。我听说有可能编写更多脚本风格的ASP.NET直接编写响应,但我没有这样做的经验,你会发现它的支持非常小。
In short: Porting raw PHP to classic ASP should be easy. Both are scripting languages which give raw access to various HTTP variables and parameters and allow the programmer to write directly to the response. If you are using a framework on the PHP or the ASP side, as you will be expected to if you use ASP.NET then things will be very different.
简而言之:将原始PHP移植到经典ASP应该很容易。两者都是脚本语言,它们提供对各种HTTP变量和参数的原始访问,并允许程序员直接写入响应。如果您在PHP或ASP端使用框架,那么如果您使用ASP.NET,那么事情将会非常不同。
#3
1
Just to get it off my chest: Why convert it at all? Running the same codebase on an IIS/PHP stack should be fairly easy.
只是为了让它脱离我的胸膛:为什么要转换它?在IIS / PHP堆栈上运行相同的代码库应该相当容易。
Having said that, take a look at the PHP to ASP.NET Migration Assistant tool Microsoft provides.
话虽如此,请看一下Microsoft提供的PHP to ASP.NET Migration Assistant工具。
The page also provides a list of items that can be converted (well, mostly anyway):
该页面还提供了可以转换的项目列表(好吧,无论如何):
- Language migration
- Built-in functions support
- Include files
- ...
内置功能支持
As well as items that can't be converted (items you'll have to completely re-write):
除了无法转换的项目(您必须完全重写的项目):
- Dynamic includes
- Declare statement
- PHP functions not completed in current script.
- ...
PHP函数未在当前脚本中完成。
#4
0
Rather than try and do the translation to a language (and stack?) you're not familiar with I'd recommend looking at something like http://www.hawhaw.de/ to do the conversion/translation for you.
你不是很熟悉,而是试图翻译成一种语言(和堆栈?),我建议你去http://www.hawhaw.de/查看为你做转换/翻译的事情。