Re: Strange behaviour overriding methods in 5.0.4

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

 



mail wrote:
Norbert Wenzel wrote:

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

did you try letting the parent class method just return a string constant?


The method in parent class just returns a string constant. I'm at home right no, but as far as I remeber it looks pretty much like this:
public function getTitle() { //in parent class View
return 'My Company:';
}

   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:

current version in NoLoggedUserView I presume, whats the definition
in the parent class?

yes, in no logged user view.
See the parent class above.
   public function getTitle() {
       //return 'NoLoggedTitle'; // works great
       //return parent::getTitle(); // no changes are made

what if there is no parent?

there is, because it's just a test to see if i get this working. until yesterday i just called $_SESSION['view']->getTitle() and since this was an instance of View the method should be at least available in View.

what did you upgrade? when was the last time you rebooted (assuming windows ;-)?
maybe give your webserver a restart?


I would like to do so, but the page doesn't even load a blank page on error. the page stays the same as it was before, so if do reload nothing happens, just as if the page doesn't get compiled or so. but then again, if i change the page, so it doesn't need to call any parent:: stuff, it compiles and loads without any errors.
so it looks like the page isn't even compiled when calling parent:: ...

nonsense me thinks - its crashing somwhow. if you turn off output buffering
and echo stuff out prior to the fatal call you should get some output.


--
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