title: Call static method from string in PHP
body: <p>I'm trying to call this from string <code>Yii::app()-&gt;user-&gt;id_rol</code>. So, I want to take this string and do the call then.</p>
  
  <p>I tried to do this:</p>
  
  <pre><code>$class = "Yii::app()-&gt;user-&gt;id_rol";
  $class = explode('::',$class);
  $class[1] = explode('-&gt;',$class[1]); 
  
  $class2 = new $class[0];
  $string = "";
  $n = count($class[1]);
  for($i = 0; $i&lt;$n;$i++){
  (($i+1) == $n) ? $fl = '' : $fl = '-&gt;';
  $string .= $class[1][$i].$fl;
  }
  
  $model = $class2-&gt;$string;
  </code></pre>
  
  <p>...but that doesn't work.</p>
  
  <blockquote>
    <p>Undefined property: Yii::$app()->user->id_rol </p>
  </blockquote>
  
  <p>How could I make it work?</p>