Detecting syntax errors inside php function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ogosensedan
Forum Newbie
Posts: 2
Joined: Wed Feb 18, 2009 2:14 am

Detecting syntax errors inside php function

Post by ogosensedan »

Hello,

I just spent at least half an hour debugging a simple syntax error:

if(isset($_POST['firstname'])) $mailbody = $mailbody . "First Name: " . $_POST['firstname'];

The yello marked dot was forgotten (it's almost invisible, i'm sorry).

The problem is that this code was part of a php function that is in a file that's part of Joomla component, so once it happened (syn error), all I got as a result was an empty page.

I know this might sound silly for people that know the solution, but I'm wondering hwo to track this kind of errors. Is there a solution?

Best,
Dan
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Detecting syntax errors inside php function

Post by requinix »

Enable display_errors. On a production environment this can be a bad thing, especially for newbie coders. You introduce an error, people will see it. If a bad person sees it and it's a certain type of error then you can have problems - beyond just buggy PHP code.

It's a php.ini setting. Enable that on your test system, do your work on that, and when it works correctly you copy files.
ogosensedan
Forum Newbie
Posts: 2
Joined: Wed Feb 18, 2009 2:14 am

Re: Detecting syntax errors inside php function

Post by ogosensedan »

Thank you, I will.
Post Reply