Watch for parser errors at the End of Feed (EOF). If the parser error line number is the very bottom of your script then you likely have a braces mismatch. These can be very difficult to spot if you’ve added a bunch of code without running the program. Here’s an example of a braces mismatch: <?php
$flag = 0;
$names =
array(‘TDavid’,‘php-scripts.com’,);
foreach($names as $each) {
if($each == ‘TDavid’) {
$flag = 1;
if($flag == 1) {
print ‘I found TDavid’;
}
}
?>
Can you spot the brace mismatch above? It should be directly below the $flag=1; One way in coding that you can cut down on brace mismatches is always indent. Let’s rewrite the code above with indenting below:
<?php
$flag = 0;
$names =
array(‘TDavid’,‘php-scripts.com’,);
foreach($names as $each) {
if($each == ‘TDavid’) {
$flag = 1;
}
if($flag == 1) {
print ‘I found TDavid’;
}
}
?>
Notice how the braces match up? If you indent your code you’ll keep braces closed. There are also some helper text editor programs that will watch for brace mismatches and alert you to this common error.