#25850 [Bgs]: SWITCH

From: Date: Mon, 13 Oct 2003 12:23:03 +0000
Subject: #25850 [Bgs]: SWITCH
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-48918@lists.php.net to get a copy of this message
 ID:               25850
 User updated by:  jakespotgieter at hotmail dot com
 Reported By:      jakespotgieter at hotmail dot com
 Status:           Bogus
 Bug Type:         Zend Engine 2 problem
 Operating System: Windows
 PHP Version:      5CVS-2003-10-13 (dev)
 New Comment:

Sorry, I wrote this code quickly, trust me its got nothing to do with a
parse error. It doesnt work on the Zend engine 2. I ported it back to
4.3, and it worked. I didnt change anything in the code.

SWITCH ($_GET['method']){
  CASE 'Foo':
     //do something
  BREAK;
CASE 'Bar':
     if($i == true){
        header("location:?method=Foo");
     }else{
      //do something else  
     }
  BREAK;
}


Previous Comments:
------------------------------------------------------------------------

[2003-10-13 07:55:12] tony2001@php.net

Not a bug, but wrong syntax.

------------------------------------------------------------------------

[2003-10-13 07:42:27] tony2001@php.net

There is parse error in your code:
you forgot to add semicolon at the end of line with Header().
This code cannot be parsed correctly neither under PHP5CVS, nor
PHP4.3.3.
Having this error fixed, code works ok (but complies on undefined
variables).
So, this is problem of your code.

------------------------------------------------------------------------

[2003-10-13 07:25:43] jakespotgieter at hotmail dot com

Description:
------------
When there are multiple cases within a switch block, if you try to use
the header function, more specifically header("location:$url") it
doesn't work. When I ran the same code under 4.3.3 it worked.

Reproduce code:
---------------
SWITCH ($_GET['method']){
  CASE 'Foo':
     //do something
  BREAK;
CASE 'Bar':
     if($i == true){
        header("location:?method=Foo")
     }else{
      //do something else  
     }
  BREAK;
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=25850&edit=1


Thread (8 messages)

« previous php.bugs (#48918) next »