简述:我们编写程序时,无论怎样小心谨慎,犯错总是在所难免的。这些错误通常会迷惑PHP编译器。如果开发人员无法了解编译器报错信息的含义,那么这些错误信息不仅毫无用处,还会常常让人感到沮丧。
我们编写程序时,无论怎样小心谨慎,犯错总是在所难免的。这些错误通常会迷惑PHP编译器。如果开发人员无法了解编译器报错信息的含义,那么这些错误信息不仅毫无用处,还会常常让人感到沮丧。
编译PHP脚本时,PHP编译器会尽其所能报告它遇到的第一个问题。这样就产生一个问题:只有当错误出现时,PHP才能将它识别出来(本文后面对此问题进行了详细描述)。正是由于这个缘故,编译器指出出错的那行,从表面上看来可能语法正确无误,或者可能是根本就不存在的一行!
更好地理解错误信息可以大大节省确定并改正错误内容所花费的时间。因此,在本文中,我将努力阐明多种不同类型的PHP报错信息,以及在开发过程中如何正确理解各种报错信息的含义。
本文中所讲述的内容与您所应用的PHP的版本无关,因为本文所描述的各种错误并不限定于某一特殊版本的特定错误。另外我们假定您是一位初级或者中级程序员,并已经从事编程工作有半年或一年的时间。
编译器的工作方式:
要搞清楚编译器为什么会报告某一行上存在错误,首先必须明确编译器解析PHP代码的机制。我并不打算在本文中对此进行详细论述,但是,我们将会讨论一些更易于引发错误的简单概念。
变量声明:
如果在一条语句中声明一个变量,具体方式如下所示: $variable = 'value';
编译器首先求出语句右半部分的值(即等号右边的所有内容)。在一些编程书籍中,将此表示为语句的 RHS (右半部分)。恰恰正是语句的这一部分常常会引发错误。如果使用的语法不正确,就会出现解析错误。
解析错误:Parse error:解析错误,unexpected T_WHILE in c:program filesapache groupapachehtdocsscript.php on line 19
每次确定了前一错误时,解析错误一个接一个地不断出现。因为PHP在第一个解析错误之后就停止执行脚本,调试并纠正这一系列的错误往往会让人觉得特别厌烦。
而且,解析错误具有很少的信息,几乎不报告错误所在的行号。具体原因就是当出现错误时,编译器判定好几行的语法看起来应该是有效的,直至遇到无效的语法,最可能的情形就是表达式中使用了预定义的字词,例如:
while = 10; // Bad ? while 就是一个预定义字词,不能分配给一个值
波比源码 » 如何正确理解PHP的错误信息
buy levofloxacin 250mg pill levofloxacin 500mg sale
dutasteride brand buy celebrex pills order zofran online cheap
spironolactone medication propecia 1mg price purchase diflucan
order ampicillin 250mg without prescription cost cephalexin 250mg erythromycin 500mg brand
order sildenafil 100mg generic buy nolvadex 20mg pills methocarbamol without prescription
purchase sildenafil sildalis canada order estradiol without prescription
cost lamictal 50mg tretinoin cream canada tretinoin for sale
order tadalis without prescription order diclofenac for sale buy diclofenac 50mg sale
indomethacin 75mg for sale order terbinafine 250mg online cheap buy amoxicillin 500mg sale
cheap cialis 40mg mens erections cheap viagra generic
tadalafil 5mg ohne rezept sildenafil 50mg ohne rezept viagra kaufen für männer
accutane 20mg over the counter purchase stromectol generic stromectol sales
buy doxycycline 200mg online order generic vardenafil 20mg order furosemide 100mg
order clonidine 0.1 mg for sale catapres 0.1 mg for sale tiotropium bromide 9mcg uk
order buspar 10mg for sale cheap amiodarone 100mg ditropan brand
cheap terazosin 5mg buy actos sale buy sulfasalazine 500mg generic
bupropion 150mg cost bupropion 150 mg usa buy generic quetiapine 50mg
order salbutamol 100 mcg pill sildenafil 200mg sildenafil 100mg generic
cost tadalafil 5mg brand prozac 40mg guaranteed viagra overnight delivery usa
purchase revia online cheap order abilify without prescription abilify 30mg over the counter
order modafinil without prescription stromectol 12mg price stromectol 6 mg
buy accutane 20mg generic accutane 20mg us deltasone 10mg us
how much is cialis tadalafil price real viagra
buy furosemide pill lasix 100mg usa cost plaquenil 400mg
tadalafil 20mg oral tadalafil price buy anafranil 50mg without prescription
order chloroquine olumiant over the counter baricitinib drug
buy zyprexa online order generic valsartan 80mg order diovan for sale
norvasc 5mg canada cheap sildenafil 100mg cialis pill
lopressor 50mg over the counter buy metoprolol 50mg online vardenafil brand
clomid 50mg brand buy albuterol 2mg online free blackjack online
order triamcinolone 10mg for sale loratadine online clarinex 5mg price
priligy brand buy cytotec 200mcg for sale synthroid 100mcg pill
orlistat 60mg tablet cheap xenical 120mg buy zovirax 800mg online cheap
buy tadalafil 40mg pill inderal pill clopidogrel 75mg pills
buy zyloprim 300mg pill order rosuvastatin 10mg without prescription order zetia 10mg pill
methotrexate over the counter methotrexate 5mg canada metoclopramide brand
ozobax online toradol 10mg sale buy toradol pill
buy imitrex 50mg sale order sumatriptan 50mg online dutasteride drug
order zantac 300mg online cheap celecoxib us order celecoxib online cheap
buy cialis 10mg pills cialis tadalafil 5mg cipro 500mg sale
buy zocor 10mg generic buy zocor sale proscar 5mg pill
order cephalexin 500mg generic order erythromycin for sale buy erythromycin 250mg
order cialis without prescription order cialis for sale viagra overnight delivery
canadian viagra online pharmacy real viagra 100mg cialis 5mg pill
play blackjack real poker online generic for cialis
buy desyrel 50mg without prescription aurogra 100mg canada order sildenafil 50mg pills
pay for paper writing stromectol buy online stromectol over the counter
buy deltasone 5mg pill amoxicillin 250mg tablet generic amoxicillin 500mg