Strange behaviour overriding methods in 5.0.4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, i have a very strange example of code. Maybe you know where my
mistake could be.

I've got an index.php with a few div's and a short php code, like:
<div>echo $_SESSION['view']->getContent();</div>

The view is in every case one of my view objects. And there's the problem.

In my specific case $_SESSION['view'] is of class "NoLoggedUserView",
which of course extends "View". The "View" class containts a few public
methods, namely

	getTitle()
	getHeadline()
	getSelection()
	getSubselection()
	getContentHeadline()
	getContent()
	getFunctions()

The child class "NoLoggedUserView" contains only the
getContent()-method, which provides a login window.

But of course I still call all the other methods like getTitle() in my
index.php.

Until yesterday I encountered no problems with that, but today, if i
call $noLoggedUserView->getTitle() in the index.php i get an empty
document. No error, no warning, no notice ... nothing. The page stays
the same and doesn't change. Even the timestamp I print out to check if
there has been a change, doesn't change.

I tested a few things:
The page loads fine and without any problems, if the public method
getTitle() is written in the NoLoggedUserView and the method returns a
stupid string. If getTitle() in NoLoggedUserView looks like this
	public function getTitle() {
		return parent::getTitle();
	}
there is the same problem as before. I get an empty page, no changes are
made.

My current version of getTitle() looks like this:
	public function getTitle() {
		//return 'NoLoggedTitle'; // works great
		//return parent::getTitle(); // no changes are made
				
		$classname = get_parent_class($this);
		$v = new $classname();
		return $v->getTitle(); // works great
	}

And again, this strange thing works.

So what could cause php to act like this? Any ideas or suggestions or at
least assumptions?

Please, I really don't know where to search the mistake..

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux