witchy478 Posted June 28, 2012 Share Posted June 28, 2012 Hi I'm using a zend framework with wamp installed. When I try using $this->message for example I get this error: Fatal error: Using $this when not in object context in C:\wamp\www\myproject\application\views\scripts\index\index.php on line 2 How do I solve this? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/264920-this-problem/ Share on other sites More sharing options...
Rage Posted June 28, 2012 Share Posted June 28, 2012 Hi I'm using a zend framework with wamp installed. When I try using $this->message for example I get this error: Fatal error: Using $this when not in object context in C:\wamp\www\myproject\application\views\scripts\index\index.php on line 2 How do I solve this? Thank you You are using $this-> outside of a class, $this can only be used to access things in its own class Quote Link to comment https://forums.phpfreaks.com/topic/264920-this-problem/#findComment-1357643 Share on other sites More sharing options...
witchy478 Posted June 28, 2012 Author Share Posted June 28, 2012 In my IndexController.php I have class IndexController extends Zend_Controller_Action { public function indexAction() { $this->view->message = 'This is my new Zend Framework project!'; } } and in my index.php I have <h1>Hello World</h1> <?php echo $this->message ?> Quote Link to comment https://forums.phpfreaks.com/topic/264920-this-problem/#findComment-1357647 Share on other sites More sharing options...
Rage Posted June 28, 2012 Share Posted June 28, 2012 post your entire php script so i can see more Quote Link to comment https://forums.phpfreaks.com/topic/264920-this-problem/#findComment-1357649 Share on other sites More sharing options...
witchy478 Posted June 28, 2012 Author Share Posted June 28, 2012 I also have layout.phtml <?php echo $this->doctype(); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php echo $this->headTitle() ?> <?php echo $this->headLink() ?> <?php echo $this->headScript() ?> </head> <body> <?php echo $this->layout()->content ?> </body> </html> other then that, it's all I have for now. Quote Link to comment https://forums.phpfreaks.com/topic/264920-this-problem/#findComment-1357650 Share on other sites More sharing options...
scootstah Posted June 28, 2012 Share Posted June 28, 2012 I don't know much about the Zend framework but, after briefly looking at their documentation, it looks like you need to be doing other things in your controller before you can use variables in your view. Here is the two articles I was looking at: Controllers Views Quote Link to comment https://forums.phpfreaks.com/topic/264920-this-problem/#findComment-1357653 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.