php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #12554 switch() bug
Submitted: 2001-08-03 10:15 UTC Modified: 2002-04-27 15:56 UTC
From: lee at mediawaveonline dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.6 OS: linux
Private report: No CVE-ID: None
 [2001-08-03 10:15 UTC] lee at mediawaveonline dot com
<?
 switch($search)
 {
  case 'date':
   echo 'date';
   break;
  case 'people':
   echo 'people';
   break;
  case 'keyword':
   echo 'keyword';
   break;
  default:
   echo 'default';
   break;
 }
?>

Warning:  Undefined variable:  search in
/home/httpd/vhosts/mediawaveonline/test2.php on line 4
Warning:  Undefined variable:  search in
/home/httpd/vhosts/mediawaveonline/test2.php on line 7
Warning:  Undefined variable:  search in
/home/httpd/vhosts/mediawaveonline/test2.php on line 10

if you ask me, I should get a warning on line 2 where the switch is, not on
4, 7, 10 where the case statements are.

php 4.0.5 cgi does not do this.

  Chris Lee
  lee@mediawaveonline.com


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-03 11:42 UTC] andy@php.net
reclassified (This is not a "bug")
 [2001-08-03 14:46 UTC] jeroen@php.net
error_reporting has been set to E_ALL in your config.

Set to E_ALL & ~E_NOTICE to prevent this warning, but the point is that $search has no value in your script!

Always var_dump your variables to see what they are first.

Not a bug -> bogus
 [2001-08-03 14:48 UTC] jeroen@php.net
Ignore my comments, I misread it. Sorry
 [2002-04-27 15:56 UTC] jimw@php.net
This bug has already been fixed in the latest released version of
PHP, which you can download at http://www.php.net/downloads.php


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 13:01:30 2024 UTC