oop - PHP get_called_class() as variable for referencing static property

663

I'm trying every variation of the following to refer to a static property:

get_called_class()::$$prop

I've tried this:

${get_called_class()}::$$prop

I've tried many things, but can't seem to get it.

I know I can just do this:

$className = get_called_class();
$className::$$prop

BUT, that means an extra line of code. Surely there must be a way for the language to make this work on the same line. Anyone have a solution?

(By the way, the static property is protected, so it fails with ReflectionClass::getStaticPropertyValue.)

People are also looking for solutions to the problem: Webservice in PHP + Codeigniter. REST X SOAP

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.