Jump to content

$this problem


witchy478

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/264920-this-problem/#findComment-1357643
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/264920-this-problem/#findComment-1357650
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/264920-this-problem/#findComment-1357653
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.