PHP - cant call for function inside double quotes

The Best picture The Best · Jan 7, 2014 · Viewed 8.1k times · Source

i have a php code :

class Test {
    function someThing(){ return 1}
}

$test = new Test();

//why this isnt printing bla bla bla 1 ????
echo "bla bla bla $test->someThing()";

but it seems like i cant call function inside a double quoted string

how can i do this ?

thanks

Answer

Nimrod007 picture Nimrod007 · Jan 7, 2014

you can only call variables inside a string

but if you use {} you can add code to the block

try this :

    echo "bla bla bla {$test->someThing()}";