Re: note 15233 added to language.types.type-juggling
| From: | Jeroen van Wolffelaar | Date: | Sun, 02 Sep 2001 18:34:17 +0000 |
| Subject: | Re: note 15233 added to language.types.type-juggling | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-17538@lists.php.net to get a copy of this message | ||
This is a hack commenly used in Java, but in PHP there's a much better
alternative: (string).
Better because it is more clear.
--jeroen
----- Original Message -----
From: <matt-nospam@sprynewmedia.com>
Newsgroups: php.notes
To: <php-notes@lists.php.net>
Sent: Sunday, September 02, 2001 7:22 PM
Subject: note 15233 added to language.types.type-juggling
> Easy way to cast something like the result of a function to a string:
>
> $myString = '' . $db->f('arg');
>
> Concatenating the empty quotes changes the result to a string no matter
what type the result is. For instance the $db object might be returning an
int in this case, but $myString will have the string equivalent in it.
>
> Matt.
>
> http://www.php.net/manual/en/language.types.type-juggling.php
>