Monday, 25 May 2009

Instruction terminator, Error displayed by PHP Parser

The instruction terminator is known as the semicolon (;), is definitely required at the end of each commands. It will tells PHP parser:"this command is done, lets move on to next command".

If we do not end commands with the semicolon, the PHP Parser will confuse and show error to us.

My practices below illustrate popular problems in php coding and their fixing method.

firstly, I get a error with semicolon. there are 2 lines, one ends with semicolon, another does not. By PHP Syntax checking function from PHP Designer, I got a warning message with highlighted pink color.



In web browser preview, the PHP Parser shows me an error message.



On line number 2, I input a semicolon at the end of the command.



the error is gone now and the fixing method is finished.

Besides that, another problem can occur during coding process is quotation marks. When we use quotation marks inside other quotation marks, the inner pair must be delineated from the outside pair using the escape (\) character (also known as a backslash).

In my practice, a pink highlighted line which has a word COOL inside (" "), a warning error is marked on the left side of php designer.



On the broswer, I also have a warning message.



The error cause the problem is a set of quotation marks within another set of quotation marks.

I have a simple fix on line number 5:

echo"PHP is really \"COOL\"";

A result after fixing:



On the other hand, I also replace quotation marks ("") with (''). the code will be:

echo"PHP is really 'COOL' ";

A result will appear :

No comments:

Post a Comment