µ±Ç°Î»ÖãºLinux½Ì³Ì - Linux×ÊѶ - ´íµÄÃ÷Ã÷°×°×ÕýÈ·Àí½â PHP µÄ´íÎóÐÅÏ¢

´íµÄÃ÷Ã÷°×°×ÕýÈ·Àí½â PHP µÄ´íÎóÐÅÏ¢

¡¡¡¡ÎÒÃDZàд³ÌÐòʱ£¬ÎÞÂÛÔõÑùСÐĽ÷É÷£¬·¸´í×ÜÊÇÔÚËùÄÑÃâµÄ¡£ÕâЩ´íÎóͨ³£»áÃÔ»óPHP±àÒëÆ÷¡£Èç¹û¿ª·¢ÈËÔ±ÎÞ·¨Á˽â±àÒëÆ÷±¨´íÐÅÏ¢µÄº¬Ò壬ÄÇôÕâЩ´íÎóÐÅÏ¢²»½öºÁÎÞÓô¦£¬»¹»á³£³£ÈÃÈ˸е½¾ÚÉ¥¡£¡¡¡¡¡¡¡¡±àÒëPHP½Å±¾Ê±£¬PHP±àÒëÆ÷»á¾¡ÆäËùÄܱ¨¸æËüÓöµ½µÄµÚÒ»¸öÎÊÌâ¡£ÕâÑù¾Í²úÉúÒ»¸öÎÊÌ⣺ֻÓе±´íÎó³öÏÖʱ£¬PHP²ÅÄܽ«Ëüʶ±ð³öÀ´£¨±¾ÎĺóÃæ¶Ô´ËÎÊÌâ½øÐÐÁËÏêϸÃèÊö£©¡£ÕýÊÇÓÉÓÚÕâ¸öÔµ¹Ê£¬±àÒëÆ÷Ö¸³ö³ö´íµÄÄÇÐУ¬´Ó±íÃæÉÏ¿´À´¿ÉÄÜÓï·¨ÕýÈ·ÎÞÎ󣬻òÕß¿ÉÄÜÊǸù±¾¾Í²»´æÔÚµÄÒ»ÐУ¡¡¡¡¡¡¡¡¡¸üºÃµØÀí½â´íÎóÐÅÏ¢¿ÉÒÔ´ó´ó½ÚÊ¡È·¶¨²¢¸ÄÕý´íÎóÄÚÈÝËù»¨·ÑµÄʱ¼ä¡£Òò´Ë£¬ÔÚ±¾ÎÄÖУ¬ÎÒ½«Å¬Á¦²ûÃ÷¶àÖÖ²»Í¬ÀàÐ͵ÄPHP±¨´íÐÅÏ¢£¬ÒÔ¼°ÔÚ¿ª·¢¹ý³ÌÖÐÈçºÎÕýÈ·Àí½â¸÷ÖÖ±¨´íÐÅÏ¢µÄº¬Òå¡£¡¡¡¡¡¡¡¡±¾ÎÄÖÐËù½²ÊöµÄÄÚÈÝÓëÄúËùÓ¦ÓõÄPHPµÄ°æ±¾Î޹أ¬ÒòΪ±¾ÎÄËùÃèÊöµÄ¸÷ÖÖ´íÎó²¢²»ÏÞ¶¨ÓÚijһÌØÊâ°æ±¾µÄÌض¨´íÎó¡£ÁíÍâÎÒÃǼٶ¨ÄúÊÇһλ³õ¼¶»òÕßÖм¶³ÌÐòÔ±£¬²¢ÒѾ­´Óʱà³Ì¹¤×÷ÓаëÄê»òÒ»ÄêµÄʱ¼ä¡£¡¡¡¡¡¡¡¡±àÒëÆ÷µÄ¹¤×÷·½Ê½¡¡¡¡Òª¸ãÇå³þ±àÒëÆ÷Ϊʲô»á±¨¸æijһÐÐÉÏ´æÔÚ´íÎó£¬Ê×ÏȱØÐëÃ÷È·±àÒëÆ÷½âÎöPHP´úÂëµÄ»úÖÆ¡£ÎÒ²¢²»´òËãÔÚ±¾ÎÄÖжԴ˽øÐÐÏêϸÂÛÊö£¬µ«ÊÇ£¬ÎÒÃǽ«»áÌÖÂÛһЩ¸üÒ×ÓÚÒý·¢´íÎóµÄ¼òµ¥¸ÅÄî¡£¡¡¡¡¡¡¡¡±äÁ¿ÉùÃ÷¡¡¡¡Èç¹ûÔÚÒ»ÌõÓï¾äÖÐÉùÃ÷Ò»¸ö±äÁ¿£¬¾ßÌ巽ʽÈçÏÂËùʾ£º¡¡¡¡¡¡¡¡$variable = 'value';¡¡¡¡¡¡¡¡±àÒëÆ÷Ê×ÏÈÇó³öÓï¾äÓҰ벿·ÖµÄÖµ£¨¼´µÈºÅÓұߵÄËùÓÐÄÚÈÝ£©¡£ÔÚһЩ±à³ÌÊé¼®ÖУ¬½«´Ë±íʾΪÓï¾äµÄ RHS £¨ÓҰ벿·Ö£©¡£Ç¡Ç¡ÕýÊÇÓï¾äµÄÕâÒ»²¿·Ö³£³£»áÒý·¢´íÎó¡£Èç¹ûʹÓõÄÓï·¨²»ÕýÈ·£¬¾Í»á³öÏÖ½âÎö´íÎ󡣡¡¡¡¡¡¡¡½âÎö´íÎó¡¡¡¡Parse error:½âÎö´íÎó£¬uneXPected T_WHILE in c:\program files\apache group\apache\htdocs\script.php on line 19¡¡¡¡¡¡¡¡Ã¿´ÎÈ·¶¨ÁËÇ°Ò»´íÎóʱ£¬½âÎö´íÎóÒ»¸ö½ÓÒ»¸öµØ²»¶Ï³öÏÖ¡£ÒòΪPHPÔÚµÚÒ»¸ö½âÎö´íÎóÖ®ºó¾ÍÍ£Ö¹Ö´Ðнű¾£¬µ÷ÊÔ²¢¾ÀÕýÕâһϵÁеĴíÎóÍùÍù»áÈÃÈ˾õµÃÌرðÑá·³¡£¡¡¡¡¡¡¡¡¶øÇÒ£¬½âÎö´íÎó¾ßÓкÜÉÙµÄÐÅÏ¢£¬¼¸ºõ²»±¨¸æ´íÎóËùÔÚµÄÐкš£¾ßÌåÔ­Òò¾ÍÊǵ±³öÏÖ´íÎóʱ£¬±àÒëÆ÷Åж¨ºÃ¼¸ÐеÄÓï·¨¿´ÆðÀ´Ó¦¸ÃÊÇÓÐЧµÄ£¬Ö±ÖÁÓöµ½ÎÞЧµÄÓï·¨£¬×î¿ÉÄܵÄÇéÐξÍÊDZí´ïʽÖÐʹÓÃÁËÔ¤¶¨ÒåµÄ×Ö´Ê£¬ÀýÈ磻¡¡¡¡¡¡¡¡while = 10; // Bad ? while ¾ÍÊÇÒ»¸öÔ¤¶¨Òå×Ö´Ê£¬²»ÄÜ·ÖÅä¸øÒ»¸öÖµ¡¡¡¡¡¡¡¡Ô¤¶¨ÒåµÄ×Ö´Ê°üÀ¨ while¡¢functionµÈ£¬Èç¹ûPHPʹÓà uses to evaluate your code. Äú²»ÄÜʹÓÃÕâЩԤ¶¨Òå×Ö´ÊÀ´ÃüÃû±äÁ¿£¬¶øÇÒÈç¹ûÄú·ÇÒªÕâÑù×öµÄ»°£¬PHP¾Í»á±¨³ö¸ü¶àµÄ´íÎó£¬ÕâÊÇÄúÎÞ·¨ÈÌÊÜ¡£¡¡¡¡¡¡¡¡¹ØÓÚÕâ¸öÎÊÌ⣬ÏÂÃæµÄʾÀý¿ÉÄÜ»á¶ÔÄúÓÐËù°ïÖú¡£Çë×ÉѯÔĶÁÒ»ÏÂÏÂÃæËùʾµÄPHP ´úÂ룺¡¡¡¡¡¡¡¡<?php¡¡¡¡$b = "somevalue"¡¡¡¡if($b == "somevalue"){¡¡¡¡print "Hello world!";¡¡¡¡}¡¡¡¡?>¡¡¡¡¡¡¡¡´íÎóλÓÚ"$b ="Ò»ÐУ¨ÔÚÓï¾äµÄÄ©¶ËȱÉٷֺţ©£¬ËùÒÔ´íÎóÓ¦¸ÃÊÇ"½âÎö´íÎó:µÚ3ÐÐȱÉÙ·ÖºÅ"¶Ô°É£¿¶ø²»Ó¦¸ÃÒÀ¾Ý½âÎöÆ÷Åж¨µÄ£º¡¡¡¡¡¡¡¡rse error: parse error, unexpected T_IF in c:\program files\apachegroup\apache\htdocs\ereg2.php on line 4¡¡¡¡¡¡¡¡ÔÚµÚ4ÐУ¬if() Óï¾äµÄÓï·¨ÊÇÕýÈ·µÄ¡£ÄÇô£¬±àÒëÆ÷ÊDZ»Ê²Ã´¸ø¸ãºýÍ¿ÁËÄØ£¿ÏßË÷¾ÍÊÇ"unexpected T_IF" ²¿·Ö¡£³öÏÖ "unexpected T_???"´íÎóʱ£¬ËüËù±íʾµÄº¬ÒåΪ£º±àÒëÆ÷·¢ÏÖÔÚÔ¤¶¨Òå×Ö²»Ó¦¸Ã³öÏÖµÄλÖóöÏÖ¡£T_IF ´ú±í if(), T_WHILE ´ú±í while(), T_FOR ´ú±í for()µÈ¡£¡¡¡¡¡¡¡¡ÖµµÃÇìÐÒµÄÊÇ£¬Ò»Ð©´íÎóµÄÔ­ÒòÒ²ºÜ¼òµ¥£º¡¡¡¡¡¡¡¡Óï¾äûÓÐʹÓ÷ֺÅ(;)½áÊø£¬±ÈÈçÉÏÃæµÄʾÀý¡£×Ö·û´®ÖÐȱÉÙÒýºÅ¡£¡¡¡¡¡¡¡¡ÆäËûһЩ³£¼ûµÄ´íÎó¡¡¡¡¡¡¡¡ÎÒ¼û¹ýµÄ×î³£¼ûµÄ´íÎó¾ÍÊÇ£¬µ±Ã»ÓÐʹÓôóÀ¨ºÅ( } )½áÊøÒ»¸öº¯Êý»òÕßÒ»¸öÑ­»·Ê±³öÏֵĴíÎó£¬ÕâºÜ¿ÉÄÜÊÇ×î³£¼û£¬×îÈÃÈË·³µÄ´íÎó¡£¾ßÌå´úÂëÈçÏ£º¡¡¡¡¡¡¡¡<?php¡¡¡¡function UselessFunction() {¡¡¡¡for($i < 0; $i < 10; $i++){¡¡¡¡}¡¡¡¡?>¡¡¡¡¡¡¡¡½«²úÉúÏÂÁдíÎ󣺡¡¡¡Parse error: parse error, unexpected $ in c:\program files\apache group\apache\htdocs\ereg2.php on line 9¡¡¡¡¡¡¡¡ÓÉÓÚº¯Êý UselessFunction ûÓÐʹÓôóÀ¨ºÅ( } )À´½áÊø£¬PHP±àÒëÆ÷²»¶Ï²éÕÒ±íʾ½áÊøµÄ´óÀ¨ºÅÖ±ÖÁµ½´ïÎļþĩβΪֹ¡£ÒòΪ±àÒëÆ÷δÕÒµ½Ò»¸öÆ¥ÅäµÄ´óÀ¨ºÅ£¬¾Í»á±¨¸æÎļþĩβ´¦ÓдíÎ󡣡¡¡¡¡¡¡¡Èç¹ûÕýÈ·µØ·´Ó³ÁË´úÂëµÄ²ã´Î½á¹¹£¬´íÎóÐÅÏ¢¾Í»á±äµÃ·Ç³£Ã÷ÏÔ¡£Èç¹ûûÓбêÃ÷´úÂëµÄ²ã´Î½á¹¹£¬ÄÇô×îºóÒªÏë²éÇå³þµ½µ×Íü¼ÇÁËʲôҲ»á±äµÃ¼¸ºõÊDz»¿ÉÄܵġ£ËùÒÔ£¬Çë¼Çס£¬Ò»¶¨Òª±êÃ÷´úÂëµÄ²ã´Î½á¹¹¡£Tab¼ü¿ÉÒÔºÜÈÝÒ×µØʵÏÖÕâÒ»µã¡£¶ÔºóÐøµÄ¿ª·¢ÈËÔ±À´Ëµ£¬°ÑÎÕ´úÂë¿ò¼Ü²¢¶ÔÆä½øÐÐÐÞ¸ÄÒ²»á¸üÈÝÒ×һЩ¡£¡¡¡¡¡¡¡¡mysql ´íÎó¡¡¡¡ÁíÒ»¼«ÆäÁîÈËÌÖÑáµÄ´íÎóÐÅÏ¢¾ÍÊÇ×î³£¼ûµÄMySQL´íÎó£¬Õâ³£³£Ê¹ PHPÐÂÊָе½ÆÄΪͷÌÛ£º¡¡¡¡¡¡¡¡Warning: Supplied argument is not a valid MySQL result resource in...¡¡¡¡¡¡¡¡ÉÏÃæËù±¨¸æÓдíµÄÒ»ÐпÉÄÜÊÇ£º¡¡¡¡¡¡¡¡while($row = mysql_fetch_array($result)) {¡¡¡¡¡¡¡¡²ÎÊý $result²¢²»ÊÇÒ»¸öÓÐЧµÄ×ÊÔ´¡£ÔÚÓ¢ÓïÖÐËü±íʾÒòΪ²éѯʧ°Ü£¬½«ÎÞ·¨´¦Àímysql_fetch_array¡£ÈÎÒ»²éѯµÄÓï·¨ÎÞЧ£¨ÄúÓ¦¸Ã½«²éѯ¸´ÖÆ£­Õ³Ìùµ½MySQL ¿ØÖÆ̨²Î¿¼À´½øÐвâÊÔ£©£¬»òÕßÓëÊý¾Ý¿âµÄÁ¬½Óʧ°Ü(ÕâÖÖÇé¿öÏÂÄúÓ¦¸ÃÔٴμì²éÓû§ÃûºÍ¿ÚÁîµÈ£©¡£¡¡¡¡¡¡¡¡·ÀÖ¹´íÎó·¢Éú¡¡¡¡µÚÒ»²½£¬ÖÇÄÜ´úÂëÆ÷¿É²ÉÈ¡ÒÔϼ¸²½À´Ïû³ýÏÂÁдíÎó³öÏÖ£º¡¡¡¡¡¡¡¡• ÔÚÿһÌõÓï¾äµÄĩβ´¦£¬²»±Ø¿¼ÂÇÌí¼Ó·ÖºÅ¡ª¡ªÕâÓ¦¸Ã³ÉΪһÖÖÏ°¹ß¡£¡¡¡¡¡¡¡¡• ×ÜÊÇÒª¾¡¿ÉÄܱêÃ÷´úÂëµÄ²ã´Î½á¹¹£¬Õâ¿ÉÒÔʹÄúÄܹ»²é¿´ÊÇ·ñÍü¼ÇÔÚif µ÷Óûòº¯ÊýÄ©¶ËµÈλÖÃÌí¼Ó´óÀ¨ºÅ¡£¡¡¡¡¡¡¡¡• ÇëʹÓÿÉÍ»³öÏÔʾÓï·¨µÄ±à¼­Æ÷£¨Èç Html-Kit£©¡£ÓÐÁËÕâÀà±à¼­Æ÷µÄ¸¨Öú£¬Äú¾ÍÄÜÈ·¶¨ÊÇ·ñÍü¼ÇÁËÌí¼ÓÒýºÅ£¬ÊÇ·ñȱÉٷֺŵȡ£¡¡¡¡¡¡¡¡½áÂÛ¡¡¡¡±¾ÎÄÎÒÃǶÔPHP±àÒëÆ÷¿É±¨³öµÄһЩ¿´ÆðÀ´¿ÉÄÜûÓÐʲôÒâÒåµÄ´íÎóÓÐÁËÒ»¶¨µÄÁ˽⡣ÎÒÃÇÐèÒª½«ËùѧµÄ֪ʶӦÓõ½ÈçºÎ±ÜÃâ´íÎóÒÔ¼°´íÎó³öÏÖʱÈçºÎ¾ÀÕý´íÎó¡£µ÷ÊÔÊÇÒ»¸ö¿ª·¢ÈËÔ±ËùÓй¤×÷ÖеÄ×îÖØÒªµÄ²¿·ÖÖ®Ò»¡£Ìá¸ßµ÷ÊÔЧÂÊ¿É´ó´ó¼Ó¿ìÕû¸ö¹¤×÷µÄ½ø¶È£¬Ëõ¶ÌÍê³ÉÒ»Ï³ÌËùÐ軨·ÑµÄʱ¼ä£¬Í¬Ê±»¹¿ÉÒÔÃ÷ÏÔ¼õÇá´úÂëʧ°ÜËù´øÀ´µÄ¾«ÉñѹÁ¦¡£
[1] [2] ÏÂÒ»Ò³ 

£¨³ö´¦£ºhttp://www.sheup.com£©


ÉÏÒ»Ò³ [1] [2]