0

I just saw this syntax in an application that I am reading through:

$this->CI->{$this->user_table}->selectEmail()

I've never seen the ->{} syntax before.

What does that do?

mathk
  • 7,973
  • 6
  • 45
  • 74
Austin
  • 124
  • 1
  • 9
  • It just dawned on me that is probably a way to pass in a variable in the chain. Is that correct? – Austin May 13 '14 at 08:01
  • It is a way of encapsulation expressions. First $this->user_table gets evaluated and then the other command with the value of $this->user_table. – D. Schalla May 13 '14 at 08:04

1 Answers1

3

It lets php know you want to use the resulting value as a name. For instance if the value of $this->user_table is users it tries to access the property of $this->CI->users, otherwise you would get an error trying to access it. This Might be helpful they are called 'Variable Variables' apparently.

Bryan
  • 3,449
  • 1
  • 19
  • 23