Re: strange error

From: Date: Fri, 24 Aug 2001 10:59:33 +0000
Subject: Re: strange error
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-64227@lists.php.net to get a copy of this message
Brack wrote: > if you have structure like > <html> > <?php > if (isset(...)){ > ..; > } > elseif (isset()){ > } > else { > .. > ?> > </html> > then you need to insert "}" before "</html> > or if you use syntax > Correct, in part. The last ELSE has a starting {, but no ending }. It should go before the ?> not </html>, that would place it outside the PHP code block. > <html> > <?php > if (isset()): > ..; > elseif (isset()): > ..; > else: > ..; > ?> > </html> > you have to insert "endif;" > If you think you did it but still have an error, try to count your "if" > statements and "endif;" maybe something is missing. > > Youri the correct structure would be: <html> <?php if ( condition ) { multiple ; statements for condition=true, all ended with ";" (semi-colon) ; } elseif ( other_condition) { multiple ; statements for other_condition=true, all ended with ";" (semi-colon) ; } else { other block ; of multiple lines ; } ?> </html> Note that curly braces (expression group) does not need the semicolon after them. If the IF, ELSEIF or ELSE constructs just need to execute one line then <html> <?php if (condition) echo "whatever" ; ?> </html> the constructs themselves don't need an ending semicolon Elias

« previous php.general (#64227) next »