phpstringdouble-quotes

PHP - can't call for function inside double quotes


I have a PHP code:

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

$test = new Test();

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

but it seems like I can't call function inside a double quoted string.

How can I do this?

Thanks.


Solution

  • 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()}";