summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2006-09-25 01:37:55 +0000
committerSara Golemon <pollita@php.net>2006-09-25 01:37:55 +0000
commit406f600d01051b0dc86dfff3cee00aa2d0baa428 (patch)
tree8286476bc22fecd9ee6dd4cefd1dddfcba84d5f1
parentb8f5020a923c46753650d79dd52afe7b38e88502 (diff)
downloadphp-git-406f600d01051b0dc86dfff3cee00aa2d0baa428.tar.gz
Make settype($var, 'string'); behave like $var = (string)$var;
e.g. switch between (binary) and (unicode) depending on UG(unicode)
-rw-r--r--ext/standard/type.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/standard/type.c b/ext/standard/type.c
index ca27441583..85f283f93f 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -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);