php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #2595 switch/case String is no scalar type
Submitted: 1999-10-24 02:48 UTC Modified: 1999-11-26 14:27 UTC
From: naklar at altavista dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 3.0.12 OS: all
Private report: No CVE-ID: None
 [1999-10-24 02:48 UTC] naklar at altavista dot net
2. switch/case

http://www.php.net/manual/html/control-structures.switch.html)

"The case expression may be any expression that evaluates to a scalar
type, that is, integer or floating-point numbers and strings. Arrays or
objects are meaningless in that context. "

Strings is no scalar, but a composed type. Type CHAR in Pascal is a scalar, 
which compares to a  string of length one. 

It's even under discussion, whether a real number is a scalar type.
This ist, Because the always existing rounding errors with reals may 
prohibit one to give them the attribute scalar type.

You better could tell the readers only, that they cannot use Arrays and Objects 
in switch/case, but anything else and let off the other stuff.

Anyway, thanks for your efforts,
 oK

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-11-26 14:27 UTC] rasmus at cvs dot php dot net
Fixed in CVS
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Jun 15 23:00:01 2026 UTC