Jump to content

getting a new error... well new for me :p


rhyno

Recommended Posts

Fatal error: Call to a member function on a non-object in /home/..../includes/header.php on line 6

is the result of my code... line 6 looks like this

$view=new View();
$view->SetFolderlevel(0);

and the setfolderlevel function with in the class looks like this...

function SetFolderlevel($newFolderlevel)

{$this->folderlevel = new $newFolderlevel;}

function GetFolderlevel()

{	$folderPath ="";

	for($i=0; $i<$this->folderlevel; $i++) $folderPath .="../";

	return $folderPath;

}

Any ideas on this one?

Link to comment
https://forums.phpfreaks.com/topic/90620-getting-a-new-error-well-new-for-me-p/
Share on other sites

Maybe you meant to do:

 

{$this->folderlevel = $newFolderlevel;}

 

Having the "new" in there and the 0 (zero) value you were passing it, was trying to force PHP to create a new class object called 0. i.e.  {$this->folderlevel = new 0();} which is not possible/correct.

 

FYI:

 

For your second method (function), you don't need to do a loop when you can use str_repeat(). Example:

 

function GetFolderlevel() {

 

    return str_repeat('../', $this->folderlevel);

}

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.