On Thu, 2010-04-08 at 12:00 -0400, Paul M Foster wrote:

> On Thu, Apr 08, 2010 at 04:26:08PM +0100, Ashley Sheridan wrote:
> 
> > On Thu, 2010-04-08 at 12:17 -0300, Juan wrote:
> > 
> > > 2010/4/8 Richard Quadling <rquadl...@googlemail.com>:
> > > > On 8 April 2010 15:21, Juan <j...@rodriguezmonti.com.ar> wrote:
> > > >> Hi guys,
> > > >> I'm having trouble with the following little php code [0]. The output
> > > >> from the server is : "
> > > >> * Parse error: syntax error, unexpected '{' in file.php on line 27 *
> > > >>
> > > >> Let's assume that file.php is the file that is giving me some troubles.
> > > >>
> > > >> The structure is pretty easy to understand, however I'm not able to
> > > >> solve this. Could you tell me why I'm not able to run this code.
> > > >>
> > > >> I'm running PHP5, Apache2, and Ubuntu 9.10 with sqlite, as you
> > could see.
> > > >>
> > > >> Thanks a lot,
> > > >> Juan
> > > >>
> > > >> [0] http://pastebin.com/xC4pFbfH
> > > >>
> > > >> --
> > > >> PHP General Mailing List (http://www.php.net/)
> > > >> To unsubscribe, visit: http://www.php.net/unsub.php
> > > >>
> > > >>
> > > >
> > > > http://pastebin.com/diff.php?i=2QbANWnS
> > >
> > > Thanks a lot people!.
> > >
> > > It's solved.
> > >
> > > Juan
> > >
> > 
> > 
> > The easiest way to spot these sorts of problems is by indenting the code
> > so that the opening brace matches up with the closing one:
> > 
> > function
> > {
> >     if(condition)
> >     {
> >         statement
> >     }
> >     else
> >     {
> >         foreach(var as var2)
> >         {
> >             more statements
> >         }
> >     }
> > }
> > 
> > Yes, it takes up a lot more lines, but a few line break characters
> > aren't going to impact on the size of the file, and all the while it's
> > very easy to read. If you've accidentally missed out a closing brace
> > you'll spot it immediately.
> > 
> > It's called the Allman style and has another advantage. Consider:
> 
> While we all love Ash, he is a blasphemer, as he argues against the One
> True Style, which is K&R. (Please forgive him, Lords Kernighan and
> Richie). ;-}
> 
> In the OP's case, his error was syntax (a condition after an else
> clause). But I don't know that even a syntax-highlighting editor would
> have caught his error.
> 
> Paul
> 
> -- 
> Paul M. Foster
> 


Blaspheme is a little strong :p

Thanks,
Ash
http://www.ashleysheridan.co.uk


Reply via email to