Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Why Is Magic __Get() Method Not Working Here?

$
0
0
    private function getRandomQuote()
    {
        return $this->_quotes[array_rand($this->_quotes, 1)];
    }

	public function actionIndex()
	{
		$this->render('index', array(
            'quote'=>$this->randomQuote
        ));
	}

    public function actionGetQuote()
    {
        $this->renderPartial('_quote', array(
            'quote'=>$this->randomQuote
        ));
    }

this code generates an error:

Quote

QuoteController and its behaviors do not have a method or closure named "getrandomQuote".


Why am I not able to do this in this code? The only way to get it to work would be to change randomQuote to 'quote'=>$this->getRandomQuote()

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>