I have written a class for which the constructor function has 3 arguments. In some function of the class I have to query from db like this $profit_row->operating_profit.
now instead of writing operating_profit, I want to pass it as a variable to the constructor of the class. So my whole variable becomes $profit_row->$this->num where $this->num is initialized in the constructor.
When I do this I get the following error. How to go about this. Object of class charts could not be converted to 开发者_开发知识库string
Maybe this is what you are looking for?
$profit_row->{$this->num}
$profit_row->{$this->num}
you have a precedence problem.
精彩评论