Bug #62633 [Opn->Nab]: strcasecmp does not warn user if both params are not strings
| From: | aharvey@php.net | Date: | Mon, 23 Jul 2012 01:08:46 +0000 |
| Subject: | Bug #62633 [Opn->Nab]: strcasecmp does not warn user if both params are not strings | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-172161@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62633&edit=1
ID: 62633
Updated by: aharvey@php.net
Reported by: iam4webwork at hotmail dot com
Summary: strcasecmp does not warn user if both params are not
strings
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
PHP is a weakly typed language by design: if a scalar can be coerced into the type that a function
expects, it will be.
Expected behaviour â not a bug.
Previous Comments:
------------------------------------------------------------------------
[2012-07-22 21:23:23] iam4webwork at hotmail dot com
I believe that somewhere the underlying C source code is converting the PHP TRUE,
i.e. 1 to "1"
------------------------------------------------------------------------
[2012-07-22 21:19:42] iam4webwork at hotmail dot com
Description:
------------
When I provide strcasecmp with two parameters where one is TRUE and the other is a
string, php does not generate a warning to say that the first parameter needs to
be a string and silently converts TRUE to "1" and executes.
Test script:
---------------
<?php
var_dump(strcasecmp(TRUE, "bob"));
// -49
Expected result:
----------------
I expected a parser error message.
Actual result:
--------------
-49
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62633&edit=1