Re: Class variable interpolation
- From: Curtis <dyer85@xxxxxxxxxxx>
- Date: Wed, 29 Oct 2008 00:15:51 GMT
August Karlstrom wrote:
Rik Wasmus wrote:On Tue, 28 Oct 2008 01:58:40 +0100, August Karlstrom <fusionfile@xxxxxxxxx> wrote:
Hi,
Does anyone know the correct syntax to interpolate a class variable, $x say, inside a string? I tried
"{self::$x}"
but it produces the string
{self::x}
Here it will produce '{self::}', and a notice $x isn't set.
AFAIK, with static variables, one has the same 'problem' as with constants: no interpolation possible,
If that is the case it was probably overlooked by the language developers. I see no reason why static variables could not be interpolated with the syntax above.
just use temporary variables or concatenation.
Right, but it is kind of clumsy.
Using sprintf() and its ilk is also viable, and, IMO, can be easier on the eyes than relying on variable interpolation, anyway.
August
--
Curtis
$eMail = str_replace('sig.invalid', 'gmail.com', $from);
.
- Follow-Ups:
- Re: Class variable interpolation
- From: August Karlstrom
- Re: Class variable interpolation
- References:
- Class variable interpolation
- From: August Karlstrom
- Re: Class variable interpolation
- From: Rik Wasmus
- Re: Class variable interpolation
- From: August Karlstrom
- Class variable interpolation
- Prev by Date: Re: image uploads and version control?
- Next by Date: Re: html_entity_decode + regex = profit?
- Previous by thread: Re: Class variable interpolation
- Next by thread: Re: Class variable interpolation
- Index(es):
Relevant Pages
|