]> granicus.if.org Git - php/commitdiff
Make settype($var, 'string'); behave like $var = (string)$var;
authorSara Golemon <pollita@php.net>
Mon, 25 Sep 2006 01:37:55 +0000 (01:37 +0000)
committerSara Golemon <pollita@php.net>
Mon, 25 Sep 2006 01:37:55 +0000 (01:37 +0000)
e.g. switch between (binary) and (unicode) depending on UG(unicode)

ext/standard/type.c

index ca274415833da6bada281c056d72c4c190f50fcb..85f283f93ff6663952c90840b640772dfccb2fe2 100644 (file)
@@ -113,9 +113,15 @@ PHP_FUNCTION(settype)
                convert_to_double(*var);
        } else if (!strcasecmp(new_type, "double")) { /* deprecated */
                convert_to_double(*var);
-       } else if (!strcasecmp(new_type, "string")) {
+       } else if (!strcasecmp(new_type, "binary")) { /* explicit binary cast */
                convert_to_string(*var);
-       } else if (!strcasecmp(new_type, "unicode")) {
+       } else if (!strcasecmp(new_type, "string")) { /* runtime string type */
+               if (UG(unicode)) {
+                       convert_to_unicode(*var);
+               } else {
+                       convert_to_string(*var);
+               }
+       } else if (!strcasecmp(new_type, "unicode")) { /* explicit unicode cast */
                convert_to_unicode(*var);
        } else if (!strcasecmp(new_type, "array")) {
                convert_to_array(*var);