From the course: PHP for Web Designers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Tracking down parse errors

Tracking down parse errors - PHP Tutorial

From the course: PHP for Web Designers

Start my 1-month free trial

Tracking down parse errors

Parse errors, like the ones shown on the screen here, are among the most common error messages that you're likely to see. Parse is the technical term for what happens to a PHP script when it's processed by the server. And if there's a mistake in the code, the PHP can't parse it. So, let's take a look at this error message, and see if we can find the problem in the code. It says unexpected if, and it tells us it's on line four. Now, let's go to the editing program, and look at this page. Line four, doesn't look to be anything wrong with that if to me. And in fact, there is nothing wrong with it. And this is what confuses a lot of people. It says it was on line four. What was on line four was an unexpected if. In other words, the error lies before that. If shouldn't be there. Why shouldn't it be there? Well, on line three, the semi-colon is missing. So, if we put that semi-colon in and save the page, go back to the browser and reload it. Oh dear. We've got another syntax error…

Contents