Re: self operator within a double quoted string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 17, 2013 at 7:47 PM, NaMarPi <namarpi@xxxxxxxxx> wrote:

> I would like to use self and static operators inside a double quoted
> string,
> but do not find the way to accomplish that. Could you give me a right
> direction?
>
>
> http://3v4l.org/NDkdA
>
>
> class Foo {
>
>     public static $class_prop = 'Class_Property';
>     public $object_prop = 'Object_Property';
>
>     static function printClassProp() {
>         print 'prefix_' . self::$class_prop . '_postfix' . PHP_EOL;
>         print "prefix_{\\self::$class_prop}_postfix" . PHP_EOL;       //
> <-- issue here
>     }
>
>     function printObjectProp() {
>         print "prefix_{$this->object_prop}_postfix" . PHP_EOL;
>     }
> }
>
>
> $foo = new Foo;
> $foo->printObjectProp();
>
>
> Foo::printClassProp();
>
>
Hi,

This is a bug/feature in php and is just not possible. Either use the
syntax you've used on the single quotes, or store the variable in a
temporary var before using the print.

- Matijn

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux