PHP - cant call for function inside double quotes

Try this way

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

$test = new Test();

echo 'bla bla bla ' . $test->someThing();

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

You can also put a function name inside a variable and then use that variable like a real function inside double quotes string:

$arr = [1,2,3];
$func_inside_var = 'implode';
echo "output: {$func_inside_var($arr)}" . '<br>';

Note that you can even pass paramater to that call.


you should use this

echo "".$test->someThing()."";

or with out double quoted.

echo $test->someThing();