ZF-7539: Error " Using $this when not in object context "
Description
Im a beginner in Zend Framework World ,I started with quickstart tutorial but I have a problem when I want to access a guestbook page an error is showed
Fatal error: Using $this when not in object context in D:\qt\quickstart\application\views\scripts\guestbook\index.phtml on line 1 This is my index.phtml file:
/* this is an error line */
Guestbook Entries:
- <?php echo $this->escape($entry->email) ?>
- <?php echo $this->escape($entry->comment) ?>
Comments
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-08-09T09:04:16.000+0000
I presume you're calling the index.phtml directly. Instead, you should call the index.php file (which contains the setting up of your bootstrap).
Though it's hard to know where the problem is exactly, you can be certain this is no bug in ZF. I suggest you ask your question somewhere on a public forum, or on the mailinglists.
Posted by farid (mitnick2009) on 2009-08-09T09:32:22.000+0000
I just follow the tutorial of Quickstart in Zend Framework (http://framework.zend.com/docs/quickstart/…) , I reach to the end of this doc when I want to show a guestbook index but this error is showed
Using $this when not in object context in D:\qt\quickstart\application\views\scripts\guestbook\index.phtml on line 1 This is my index.phtml file:
Posted by Matthew Weier O'Phinney (matthew) on 2009-08-12T04:39:23.000+0000
View scripts are not intended to be accessed directly via the browser; they are to be consumed by Zend_View, at which time they run within an instance of Zend_View and $this is populated. Follow the instructions in the quick start, and setup a virtual host pointing to the application's "public" directory, and then access http://yourhostname/guestbook - which will then display the correct output.