php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25850 SWITCH
Submitted: 2003-10-13 07:25 UTC Modified: 2003-10-16 01:31 UTC
From: jakespotgieter at hotmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2003-10-13 (dev) OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jakespotgieter at hotmail dot com
New email:
PHP Version: OS:

 

 [2003-10-13 07:25 UTC] 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;
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-13 07:42 UTC] 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:55 UTC] tony2001@php.net
Not a bug, but wrong syntax.
 [2003-10-13 08:23 UTC] jakespotgieter at hotmail dot com
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;
}
 [2003-10-13 11:58 UTC] sniper@php.net
The syntax of the header() call is wrong too.

 [2003-10-14 04:52 UTC] tony2001 at phpclub dot net
I can't find any bug here.
Passing to the script "?method=Bar" in query string and having $i equal to true it works well under PHP5-CVS.
If you get any errors here - copy/paste it and wrote a letter to php-general@lists.php.net
 [2003-10-16 01:31 UTC] jakespotgieter at hotmail dot com
Trust me, there were no syntax errors. I just typed a quick example to explain what I ment.
@sniper@php.net - I even tried - header("location:http://www.google.com"); and nothing happened.

It seems the bug happens when the cases in the switch statement have quite a big chunck on code in it.

Just something to look into!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 22:01:35 2025 UTC