致初学者:PHP比ASP优秀的七个理由
<DIV class=NewsContent id=NewsContentLabel>. S) K+ R( D& c# K
<P style="TEXT-INDENT: 2em"><B><A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>比<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>优秀的七个理由</B> </P>
8 g# K% j* |0 Q; G+ k: q4 K<P style="TEXT-INDENT: 2em"><A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>是微软公司实现动态网页的一种技术。<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>支持一些脚本语言,主要以VBScripp为主。与<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>相比较,你还可以选择另一中开放源代码编程语言——<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>,<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>可以运行在多种操作系统下,其中包括Linux和windows。</P>/ o4 f* s) S7 ]+ x3 i
<P style="TEXT-INDENT: 2em">虽然<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>是一种不错的技术,但从长远考虑我相信<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>在将来的技术领域里会有不凡的表现。</P>
" m1 A& a; ]8 t( X<P style="TEXT-INDENT: 2em">我认为有七个理由可以说明<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>比<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>更优秀:</P>/ Q8 ~0 t: ^6 o) q! T
<P style="TEXT-INDENT: 2em"><B>1、速度、速度、速度</B></P>' [- d8 r! t! A* \, ]$ n- a
<P style="TEXT-INDENT: 2em">当我第一次运行<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>脚本程序时,我不禁对自己说:“太快了”,当时我是在仪态166MHZ的机器上运行我的程序的,但运行的速度仍然很快。</P>" F$ k/ m$ B' a% k8 P- W8 x, p0 `
<P style="TEXT-INDENT: 2em"><A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>是永远也不会象<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>这样快的,因为<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>是建立在COM体系结构之上的。当用VBScript写<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>脚本时,实际上实在使用COM的对象,当向用户浏览器发送信息时,它用的是Response对象的write方法,当它访问<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>数据库</FONT></A>和文件系统的时候,它用的是其他的COM对象。这些COM对象的使用使运行速度下降。</P>
$ d" o. ~6 {; T* ]<P style="TEXT-INDENT: 2em">在<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>代码中,所有的工作都运行在<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>的内存空间中,也就是说<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>不是基于COM对象的,所以的他的运行速度会快一些。</P>
9 _7 |: X3 G( J' @% E" s, ]! V' K6 Y2 e<P style="TEXT-INDENT: 2em">下面是我们在MS<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>SQL</FONT></A>7 40次运行一个查询语句的执行时间统计:</P>
% R% ~. `! h. E" X$ b) L; [<P style="TEXT-INDENT: 2em"><A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A> Querying MS<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>SQL</FONT></A>7 时间(秒)</P>
0 R+ x. ~* d4 I% u0 J<P style="TEXT-INDENT: 2em">用MS<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>SQL</FONT></A> extension 01.88</P>
' a+ c0 e3 f- |<P style="TEXT-INDENT: 2em">用ODBC extension 09.54</P>1 Q" P3 A% N! a# D
<P style="TEXT-INDENT: 2em">用ODBC via COM (ADO) 17.28</P> _; d3 v- U, p( C' @
<P style="TEXT-INDENT: 2em">用OLEDB via COM 06.19</P>
& r% r; `3 V) D& H( O% N7 {% _% u<P style="TEXT-INDENT: 2em">当我们使用<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>.ODBC,访问<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>数据库</FONT></A>用了9.54秒,而用COM接口去连接<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>数据库</FONT></A>需要比<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>所用的时间高80%。</P> Z% a+ C! L) B5 n5 {: w/ @7 V
<P style="TEXT-INDENT: 2em">OLEDB是微软的一种高速访问<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>数据库</FONT></A>的技术,他比ODBC要快。但当我们所<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>和OLEDB的效率实验时,结果是<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>的整体性能比OLEDB高200%,如此的出一个结论,如果不采用COM可以获得较快的执行速度。</P>2 p9 |9 i# ?7 T& y5 N6 p
<P style="TEXT-INDENT: 2em">当然<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>的执行速度还不是最快的,但我们才刚刚开始起步,我们会逐步的完善他,而且<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>是一种开放源代码编程语言,世界上许多程序员在不断的完善他的技术,相信他一定会比非开放源代码系统获得更高的执行速度的。</P>
* Z3 y A& ?# w<P style="TEXT-INDENT: 2em"><B>2、高级内存管理</B></P>3 S# I" o. u% x# L+ w
<P style="TEXT-INDENT: 2em">在<A class=wordstyle href="http://www.jz123.cn/Article/13/155/index.html" target=_blank><FONT color=#0000ff>IIS</FONT></A>4下,一个<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>脚本header.<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">asp</A>,如果被20个页面所包含,那么运行的时候,在内存当中会保留这20个header.<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">asp</A>的编译副本,<A class=wordstyle href="http://www.jz123.cn/Article/13/155/index.html" target=_blank><FONT color=#0000ff>IIS</FONT></A>5解决了这个问题,但只有windows2000才支持<A class=wordstyle href="http://www.jz123.cn/Article/13/155/index.html" target=_blank><FONT color=#0000ff>IIS</FONT></A>5,由于这种<A class=wordstyle href="http://www.jz123.cn/Article/13/155/index.html" target=_blank><FONT color=#0000ff>IIS</FONT></A>5的不能向下兼容的原因,许多<A class=wordstyle href="http://www.jz123.cn/Article/13/index.html" target=_blank><FONT color=#0000ff>服务器</FONT></A>仍然要使用<A class=wordstyle href="http://www.jz123.cn/Article/13/155/index.html" target=_blank><FONT color=#0000ff>IIS</FONT></A>4下的低级的内存管理。</P>
7 P4 a% w; W- X; y. [<P style="TEXT-INDENT: 2em">而在<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>中,不会存在这种问题,只有当require时,才会调用某个include文件。</P>
% G1 K; B& r' U3 Y1 Z<P style="TEXT-INDENT: 2em"><B>3、没有后顾之忧</B></P>: `3 T- P" f l8 N8 T
<P style="TEXT-INDENT: 2em">我非常憎恨的一件事情就是会买到一件不放心的产品,比如当你买了一辆汽车,但由于发动机是坏的,你需要更换他;当你买了一栋房子的时候,你要去修补漏雨的屋顶。</P>
. Q V3 k& V. f! p2 z<P style="TEXT-INDENT: 2em">那么<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>旧乡这些产品一样,当你买了<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>之后,如果你需要加密技术,你就要买<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>Encrypt;当你需要Email管理时,你就要买ServerObjets Qmail;当你需要文件上传时,你还要买Artisans SA-FileUp.</P>
. h. |- ?* R' \& g! v<P style="TEXT-INDENT: 2em"><B>4、<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>MySQL</FONT></A>使<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>更精彩</B> </P>
, N0 y! P" Z$ E5 q! ?) k! j<P style="TEXT-INDENT: 2em"><A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>与<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>MySQL</FONT></A>的组合既简单又精彩。<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>有许多管理和维护<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>MySQL</FONT></A>的工具,对MySQk的支持是最全面的。许多有用的函数如<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>mysql</FONT></A>_insert_id和<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>mysql</FONT></A>_affected_rows等,其他的<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>数据库</FONT></A>则没有。</P>$ L/ n. U6 O4 ~/ l. t/ @
<P style="TEXT-INDENT: 2em"><A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>和<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>都是中型<A class=wordstyle href="http://www.jz123.cn/" target=_blank><FONT color=#800080>网站</FONT></A>的较理想的解决方案,但<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>与<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>MySQL</FONT></A>的紧密结合使<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>更加优越。</P>
0 r% x4 ]$ z! ]<P style="TEXT-INDENT: 2em"><A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>MySQL</FONT></A>的虚度比Microsoft <A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>Access</FONT></A>速度快,Ms<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>sql</FONT></A>和Oracle速度比<A class=wordstyle href="http://www.jz123.cn/Article/10/137/index.html" target=_blank><FONT color=#0000ff>MySQL</FONT></A>要快,可是费用较高。</P>* }7 t$ s; h' _4 r' ~
<P style="TEXT-INDENT: 2em"><B>5、Java和C++的变成风格</B></P>
6 c* C6 a6 ~) d) y2 {. Z. O$ z<P style="TEXT-INDENT: 2em">这个优点只是一个看法。</P>' u' i" H9 n$ p# C
<P style="TEXT-INDENT: 2em">我知道你不会相信一个Visual Basic程序员会因为<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>有Java和C++的编程风格而转向使用<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>,但你会相信有许多人还是喜欢Java和C++的,<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>是一种具有这两种语言的编程风格的较容易学习的语言。</P>
6 h; t6 a) u# B, u6 D<P style="TEXT-INDENT: 2em"><A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>支持结构化编程,在VB因为他的继承性使用类还是较少的。而<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>的象Java和C++一样的继承性使一个大型的程序中到处都充满了类的影子。</P>5 d6 B, _3 k" ^1 A7 e& m: h- H
<P style="TEXT-INDENT: 2em"><B>6、Bug的处理</B></P>
) c' w# e* v D, q1 w0 S: E<P style="TEXT-INDENT: 2em">你是否曾经要求Microsoft修改<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>的一些Bug呢?如果你不是一个象Boeing一样的组织,你无法获得迅速而恰当的修改,把么当你遇到Bug而停止工作时,如果这个Bug不修改,你将无法继续你的工作的。</P>
' a; m1 {+ T8 ^/ s7 G<P style="TEXT-INDENT: 2em"><A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>,当你发现Bug时,你可以修改他,如果你没有专家的水平,你可以请专家修改,并且你的修改会得到开放代码组织的接受和认可。</P>
/ s" A- d4 N' V# M<P style="TEXT-INDENT: 2em"><B>7、移植性</B></P>
: t* B: @' }! Y) ^8 V<P style="TEXT-INDENT: 2em">Microsoft经常修改<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>,下一版本叫<A class=wordstyle href="http://www.jz123.cn/Article/10/130/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">ASP</A>+,现在已经开始测试。我相信他们会修改许多我曾经提到过的问题。但也无庸质疑的,Microsoft会将你限制在他们的产品范围之内的。</P>! K3 R! J4 l+ K X+ c7 I
<P style="TEXT-INDENT: 2em">我曾经是一个苹果机的程序员,当windows95问世后,我开始转变,但许多原来的代码都无法在windows95下运行,这些代码现在被放在一边,我非常的遗憾。所以我不希望在windows下再出现这样的悲剧。</P> B$ O& h# N, S0 V8 @! v6 e
<P style="TEXT-INDENT: 2em">不要忘记Novell曾经也象Microsoft的网络操作系统一样热及一时,但现在已经没有许多人用了,那么Microsoft也会这样的。</P>
5 |5 x% J3 s2 {5 M<P style="TEXT-INDENT: 2em">我找到了<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>,我仍旧在windows下工作,但我知道<A class=wordstyle href="http://www.jz123.cn/Article/10/133/index.<a%20target=" target=_blank _blank?><FONT color=#0000ff>html</FONT></A>" class="wordstyle">PHP</A>代码可以运行在Solaris、Linux和许多其他的操作系统中,我的心里感到安慰</P></DIV>