|
Posted by "Rob Agar" on 09/29/05 03:22
hi Norbert,
Have you tried print_r($_SESSION['view'])? I'm wondering if there's
some problem recreating the class instance from the session data...
Rob
> -----Original Message-----
> From: Norbert Wenzel [mailto:mail@brain4art.at]
> Sent: Thursday, 29 September 2005 2:58 AM
> To: php-general@lists.php.net
> Subject: [PHP] Strange behaviour overriding methods in 5.0.4
>
>
> 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
>
Navigation:
[Reply to this message]
|