note 114499 added to function.is-string
| From: | laszlodotheredyshift-twogmailetc | Date: | Thu, 27 Feb 2014 21:22:21 +0000 |
| Subject: | note 114499 added to function.is-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198743@lists.php.net to get a copy of this message | ||
Using is_string() on an object will always return false (even with __toString()).
<?php
class B {
public function __toString() {
return "Instances of B() can be treated as a strings!\n";
}
}
$b = new B();
print($b); //Instances of B() can be treated as a strings!
print(is_string($b) ? 'true' : 'false'); //false
?>
----
Server IP: 83.137.20.135
Probable Submitter: 64.1.208.234
----
Manual Page -- http://php.net/manual/en/function.is-string.php
Edit -- https://master.php.net/note/edit/114499
Del: integrated -- https://master.php.net/note/delete/114499/integrated
Del: useless -- https://master.php.net/note/delete/114499/useless
Del: bad code -- https://master.php.net/note/delete/114499/bad+code
Del: spam -- https://master.php.net/note/delete/114499/spam
Del: non-english -- https://master.php.net/note/delete/114499/non-english
Del: in docs -- https://master.php.net/note/delete/114499/in+docs
Del: other reasons-- https://master.php.net/note/delete/114499
Reject -- https://master.php.net/note/reject/114499
Search -- https://master.php.net/manage/user-notes.php