note 23401 added to control-structures.switch

From: Date: Wed, 17 Jul 2002 15:15:15 +0000
Subject: note 23401 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-33212@lists.php.net to get a copy of this message
Note to chernyshevsky@hotmail.com: If you quote the string labels in your case statements, you should have no problem using function names as labels. I believe you are relying on the fact that php is converting your barewords to strings. In the case of the word 'print', it's a function and not just a bareword, so php is complaining about your syntax. So, your code should be: switch ($view) { case 'print': echo "Show printfriendly version"; break; default: echo "Show normal version"; } -- http://www.php.net/manual/en/control-structures.switch.php http://master.php.net/manage/user-notes.php?action=edit+23401 http://master.php.net/manage/user-notes.php?action=delete+23401 http://master.php.net/manage/user-notes.php?action=reject+23401

« previous php.notes (#33212) next »