php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8582 normal if nested in alternate if gives parse error
Submitted: 2001-01-07 20:09 UTC Modified: 2001-01-08 06:53 UTC
From: wojas at vvtp dot nl Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3pl1 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wojas at vvtp dot nl
New email:
PHP Version: OS:

 

 [2001-01-07 20:09 UTC] wojas at vvtp dot nl
The following php code gives a parse error at the 'else:'

<?php
if(1==1):
        echo "ok so far<p>";
        if(1==1) echo "error here!";
else:
        echo "Not possible";
endif;
?>

It looks like php thinks the 'else:' is part of the second 
if construct; the following code works:

<?php
if(1==1):
        echo "ok so far<p>";
        if(1==1) echo "error here!";
        echo "void";
else:
        echo "Not possible";
endif;
?>

Tested with 4.0.3pl1, 4.0.4RC3 and 3.0.18 on debian woody and potato.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-08 06:53 UTC] stas@php.net
Indeed the parser thinks else is a part of second construct
and chokes on ":". I'd suggest first to switch to newer {}
syntax, and then bracket your ifs so that you are sure you
and the parser agree on what is the part of what.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Jul 07 03:00:02 2026 UTC