]> granicus.if.org Git - php/commitdiff
Let settype also accept 'int', 'bool', 'float' and 'null'
authorJeroen van Wolffelaar <jeroen@php.net>
Sat, 22 Sep 2001 01:39:14 +0000 (01:39 +0000)
committerJeroen van Wolffelaar <jeroen@php.net>
Sat, 22 Sep 2001 01:39:14 +0000 (01:39 +0000)
@Let settype also accept 'int', 'bool', 'float' and 'null' (Jeroen)

ext/standard/basic_functions.c

index 5713c61598c131d7b1a84568aec9eb8e6e9b574c..8c6cdf8d0e59cfc5eeebc1859242653293bce6a2 100644 (file)
@@ -1443,7 +1443,11 @@ PHP_FUNCTION(settype)
 
        if (!strcasecmp(new_type, "integer")) {
                convert_to_long(*var);
-       } else if (!strcasecmp(new_type, "double")) {
+       } else if (!strcasecmp(new_type, "int")) {
+               convert_to_long(*var);
+       } else if (!strcasecmp(new_type, "float")) {
+               convert_to_double(*var);
+       } else if (!strcasecmp(new_type, "double")) { /* deprecated */
                convert_to_double(*var);
        } else if (!strcasecmp(new_type, "string")) {
                convert_to_string(*var);
@@ -1451,8 +1455,12 @@ PHP_FUNCTION(settype)
                convert_to_array(*var);
        } else if (!strcasecmp(new_type, "object")) {
                convert_to_object(*var);
+       } else if (!strcasecmp(new_type, "bool")) {
+               convert_to_boolean(*var);
        } else if (!strcasecmp(new_type, "boolean")) {
                convert_to_boolean(*var);
+       } else if (!strcasecmp(new_type, "null")) {
+               convert_to_null(*var);
        } else if (!strcasecmp(new_type, "resource")) {
                php_error(E_WARNING, "settype: cannot convert to resource type");
                RETURN_FALSE;