{$resource}; ...">

What "returns $ container & # 8594; {$ resource};" I mean

What do marriages mean and where to read next

return $container->{$resource};
+3
source share
2 answers

Two possibilities:

  • variable variable .

    $ resource = "score"; // dynamically set the name

    return $ container → {$ resource}; // same as return $ container-> score;

  • typo / novice error

The programmer should have entered:

return $container->resource;  // returns resource public member variable
+3
source

Brackets must use variable variables. This facilitates the distinction between:

// gets the value of the "resource" member from the container object
$container->resource;

and

// gets the value of the "foo" member from the container object
$resource = 'foo';
$container->$resource;

You can read more here: http://php.net/manual/en/language.variables.variable.php

+4
source

Source: https://habr.com/ru/post/1733669/


All Articles