note 65237 deleted from function.settype by bjori
| From: | bjori@php.net | Date: | Thu, 27 Apr 2006 12:00:49 +0000 |
| Subject: | note 65237 deleted from function.settype by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-109850@lists.php.net to get a copy of this message | ||
Note Submitter:
Reason: bad code
----
As per Ludwig's suggestion, settype can be used via call_user_func, keeping in mind, however,
that it must be passed by reference:
<?php
$a = 123;
$b = "string";
call_user_func("settype", &$a, &$b);
var_dump($a); // string(3) "123"
?>
As with other functions, you can also define settype dynamically:
<?php
$a = 123;
$b = "string";
$set = "settype";
$set($a, $b);
var_dump($a); // string(3) "123"
?>