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 */

Sign Our Guestbook

Guestbook Entries:

<?php echo $this->escape($entry->email) ?>
<?php echo $this->escape($entry->comment) ?>

Comments

Im a beginner in Zend Framework World Good choice! :D

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.

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:

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.