ASP.net 和 PHP 之间的根本区别是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2398926/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are the fundamental differences between ASP.net and PHP?
提问by palbakulich
Possible Duplicate:
.NET & ASP vs PHP
可能的重复:
.NET & ASP vs PHP
Are there speed differences, performance issues, and what reasons do businesses have when they choose one or the other, is the learning curve steeper for one over the other?
是否存在速度差异、性能问题以及企业在选择其中一个时有什么原因,其中一个的学习曲线是否比另一个更陡峭?
Also... are you likely to be paid more using one over the other?
另外……使用其中一种比另一种获得更高的报酬吗?
回答by John K
Microsoft has published a great overview of migrating from PHP to ASP.NET which reveals differences and similarities.
Microsoft 发布了一篇关于从 PHP 迁移到 ASP.NET 的精彩概述,其中揭示了不同之处和相似之处。
回答by James Black
ASP and PHP are similar in that both tend to put their code in with the HTML, and so the logic can be quite similar.
ASP 和 PHP 的相似之处在于都倾向于将它们的代码放在 HTML 中,因此逻辑可能非常相似。
But, ASP.NET will be very different from PHP in design, as there is a strong incentive to use code-behind in ASP.NET, where you basically have the html template and all the code is in another separate file
但是,ASP.NET 在设计上将与 PHP 大不相同,因为在 ASP.NET 中使用代码隐藏的强烈动机,在那里您基本上拥有 html 模板,所有代码都在另一个单独的文件中
Depending on what you are doing, how busy your site is, you may find that the speed difference is inconsequential, though one is compiled and the other isn't.
根据您在做什么,您的站点有多忙,您可能会发现速度差异无关紧要,尽管一个是编译的,另一个不是。
PHP is probably going to be faster to develop, as you can more easily code a little and test, than you can with ASP.NET, but ASP and PHP are similar in how you can develop.
PHP 的开发速度可能会更快,因为与使用 ASP.NET 相比,您可以更轻松地编写代码和进行测试,但是 ASP 和 PHP 在开发方式上是相似的。
If you don't know any of these languages then PHP may be the easier one to learn, as the php manual is so well written, with lots of comments from users, and ASP.NET has replaced ASP, so learning ASP for a new project, IMO, is of limited use.
如果你不知道这些语言中的任何一种,那么 PHP 可能更容易学习,因为 php 手册写得很好,有很多用户的评论,而且 ASP.NET 已经取代了 ASP,所以学习 ASP 为一个新的IMO 项目的用途有限。
If you go with ASP.NET then you are learning a new syntax and one of the .NET languages, but depending on your background, C# may be relatively easy to learn.
如果您使用 ASP.NET,那么您正在学习一种新语法和一种 .NET 语言,但根据您的背景,C# 可能相对容易学习。
With ASP or ASP.NET you are stuck with using IIS for your server, but with PHP you can use IIS or Apache, so there is considerable flexibility there.
对于 ASP 或 ASP.NET,您只能在服务器上使用 IIS,但是对于 PHP,您可以使用 IIS 或 Apache,因此那里有相当大的灵活性。
With ASP.NET you will find more options to help with code development, as they now have the classic ASP.NET and ASP.NET MVC (http://www.asp.net/%28S%28d35rmemuuono1wvm1gsp2n45%29%29/mvc/), both with pros and cons, but I believe this site is still written in the latter.
使用 ASP.NET,您将找到更多选项来帮助代码开发,因为它们现在拥有经典的 ASP.NET 和 ASP.NET MVC ( http://www.asp.net/%28S%28d35rmemuuono1wvm1gsp2n45%29%29/mvc /),各有利弊,但我相信本站还是用后者写的。
So, which would be better depends on what you are going to be doing with it, and what languages or frameworks you have already gained experience with.
因此,哪个更好取决于您将使用它做什么,以及您已经获得了哪些语言或框架的经验。
回答by JeffO
The Microsoft route will have a better learning curve if you are coming from a VB6 or other Microsoft platform. You'll probably have more hardware & licensing requirements to run the Windows Server/IIS/SQL Server/.NET platforms than LAMP. Whether or not you can manage one better than the other is a matter of skill set & probably opinion.
如果您来自 VB6 或其他 Microsoft 平台,Microsoft 路线将具有更好的学习曲线。与 LAMP 相比,您可能有更多的硬件和许可要求来运行 Windows Server/IIS/SQL Server/.NET 平台。您是否可以比另一个更好地管理一个是技能和可能意见的问题。
回答by Ben McIntyre
An really important feature of .NET is that it can be used for developing web apps (ASP .NET), desktop apps, web services, Palmtop development, in short pretty much anything (the only problem being it is not cross-platform, unless you count the open source Mono project, which is coming along well). So ASP .NET is only one part of its capability. If you were writing a suite of applications for desktop, web, palm then the same business logic libraries could be re-used for all of these projects. PHP is pretty much web-only and is specialised in that area.
.NET 的一个非常重要的特性是它可以用于开发 Web 应用程序 (ASP .NET)、桌面应用程序、Web 服务、掌上电脑开发,简而言之,几乎任何东西(唯一的问题是它不是跨平台的,除非你算上开源的 Mono 项目,它进展顺利)。因此 ASP .NET 只是其功能的一部分。如果您正在为桌面、网络、掌上电脑编写一套应用程序,那么相同的业务逻辑库可以重用于所有这些项目。PHP 几乎仅用于 Web,并且专门用于该领域。
If you are only interested in creating a web app, then PHP competes well and the learning curve would be much smaller.
如果您只对创建 Web 应用程序感兴趣,那么 PHP 的竞争力会很好,学习曲线也会小得多。
.NET is in essence Java rebadged and developed further, with the cross platform capabilities removed.
.NET 本质上是对 Java 进行了重新标记和进一步开发,删除了跨平台功能。
回答by Randolpho
The most fundamental difference between the two is the language. PHP uses a C-like syntax, while ASP uses Visual Basic as its syntax.
两者之间最根本的区别在于语言。PHP 使用类似 C 的语法,而 ASP 使用 Visual Basic 作为其语法。
ASP.NET, however, is an entirely different beast; I note you've listed ASP in your title, but ASP.NET in your tags.
然而,ASP.NET 是一个完全不同的野兽。我注意到您在标题中列出了 ASP,但在标签中列出了 ASP.NET。
ASP.NET is a templating language that can work in front of any .NET programming language, the most common being C# and VB.NET. ASP.NET uses (and comes with) the .NET framework, and is far more object-oriented than either PHP or ASP.
ASP.NET 是一种模板语言,可以在任何 .NET 编程语言之前工作,最常见的是 C# 和 VB.NET。ASP.NET 使用(并附带).NET 框架,并且比 PHP 或 ASP 更加面向对象。
In general, PHP and ASP will seem faster for many tasks, but ASP.NET will provide a better chance at building a robust, maintainable application.
一般而言,PHP 和 ASP 似乎对许多任务更快,但 ASP.NET 将提供更好的机会来构建健壮、可维护的应用程序。
回答by Edward Williams
Personally I like the flexibility you get when using PHP. However, ASP.net is quite fast to write a quick application in. It is used by a lot of large companies for web dev as well. Page layout can be done using point and click in Visual Studio though you can directly access the HTML markup and use templates, css etc.
我个人喜欢您在使用 PHP 时获得的灵活性。但是,在 ASP.net 中编写快速应用程序的速度相当快。许多大公司也将其用于 Web 开发。虽然您可以直接访问 HTML 标记并使用模板、css 等,但可以使用 Visual Studio 中的点击来完成页面布局。
With no adjustments to the languages (besides turning on page caching in asp.net) the benchmarks I have seen point to ASP.net being slightly to moderately faster.
由于没有对语言进行调整(除了在 asp.net 中打开页面缓存),我看到的基准测试表明 ASP.net 稍微快到中等速度。
The reason for this is that ASP.net is compiled whereas PHP is an interpreted language.
这样做的原因是 ASP.net 是编译的,而 PHP 是一种解释性语言。

