ID:               25850
 Comment by:       aderkach 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:

How are you calling the page?

Heres the corrected code for what you are trying to do.
-----snip------
switch ($_GET['method'])
{
        case "Foo":
            echo "Foo";
            break;
        case "Bar":
            if($i == true)
            {
                Header("Location: $PHP_SELF?method=Foo");
            }
            else
            {
                 echo '$i is not true';
            }
            break;
        default:
            echo "Something weird is going on";
}
-----snip------

URL: file.php
OUTPUT: Something weird is going on
// Expected

URL: file.php?method=foo
OUTPUT: Something weird is going on
// Expected (case-sensitivity)

URL: file.php?method=Foo
OUTPUT: Foo
// Expected

URL: file.php?method=Bar
OUTPUT: $i is not true
// Expected ($i is not true)

URL: file.php?method=Bar&i=1
OUTPUT: Foo
//Expected


Tested under Linux (2.4.21 Kernel) with PHP 4.3.2


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

[2003-10-14 04:52:54] 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
[EMAIL PROTECTED]

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

[2003-10-13 11:58:41] [EMAIL PROTECTED]

The syntax of the header() call is wrong too.


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

[2003-10-13 08:23:02] 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 07:55:12] [EMAIL PROTECTED]

Not a bug, but wrong syntax.

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

[2003-10-13 07:42:27] [EMAIL PROTECTED]

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.

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/25850

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

Reply via email to