Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find missing braces in large PHP file?

I'm debugging a client's 3500-line PHP file. Including this file causes a PHP Parse error: syntax error, unexpected $end in ... error, so I'm assuming there's a missing brace somewhere. Is there a simple tool or method for missing brace discovery, either online or in the Komodo IDE I'm using?

like image 964
Yarin Avatar asked Feb 13 '12 18:02

Yarin


3 Answers

Use consistent and clean tabbing. I've found that makes it very hard to miss a closing brace.

Other than that, you've kinda dug your own grave here. What are you coding that results in a 3500-line PHP file?

EDIT: Try dumping your code into Notepad++. I'm fairly sure that will highlight the associated closing brace if you click on the opening one, but with larger files, I've gotten somewhat unreliable performance with this.

like image 139
tnw Avatar answered Sep 20 '22 14:09

tnw


another option (similar to notepad++) is to use Dreamweaver to find the associated closing tag.
See this link: How do I make Dreamweaver to show me closing tags?

in dreamweaver:
To select matching opening and closing curly braces, brackets, or parentheses, click inside the opening or closing symbol, and click the Balance Braces button on the Coding toolbar (it's immediately below Select Parent Tag). Alternatively, use the keyboard shortcut, Ctrl+'/Cmd+'.

like image 45
user1628848 Avatar answered Sep 18 '22 14:09

user1628848


Use NetBeans IDE for PHP.
http://netbeans.org/features/php/

Will check your syntax and highlight issues amongst the many other nice features it has. And it's free.

like image 42
Jeff Avatar answered Sep 18 '22 14:09

Jeff