Re: Class variable interpolation



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.


August
.



Relevant Pages

  • Re: Class variable interpolation
    ... Does anyone know the correct syntax to interpolate a class variable, $x say, inside a string? ... AFAIK, with static variables, one has the same 'problem' as with constants: no interpolation possible, just use temporary variables or concatenation. ...
    (comp.lang.php)
  • Re: Class variable interpolation
    ... Does anyone know the correct syntax to interpolate a class variable, $x say, inside a string? ... I see no reason why static variables could not be interpolated with the syntax above. ... Using sprintfand its ilk is also viable, and, IMO, can be easier on the eyes than relying on variable interpolation, anyway. ...
    (comp.lang.php)
  • Re: perl array issue
    ... http://en.wikipedia.org/wiki/Code_ (cryptography): ... You do realize that backticks interpolate, ... before the string is passed to the shell. ... Sinan Unur ...
    (comp.lang.perl.misc)
  • Re: Hex strings treated differently when read from STDIN?
    ... > Not sure why Perl doesn't recognize the string in Ex. ... interpolate and in transliterations. ... use warnings; ... Sinan Unur ...
    (comp.lang.perl.misc)
  • Re: qr + shift
    ... it's because shift *is* a function. ... As OP's example shows, variables interpolate, functions don't. ... It doesn't matter whether the interpolated string is ...
    (perl.beginners)