Reply to Is a static class member not restored after session reload?

Your name:

Reply:


Posted by Gert Kok on 01/19/08 19:40

I'd like to use 3 types of objects, which have a kind of
availability-check as a static object in their parent class.

After page reload the initialised member is NULL


Is this a PHP 5.2.5 feature or am I missing something?

------------------------------------------------
First page in a session:
------------------------------------------------
session_start();

class Checker {

function check () {
echo 'OK';
}

}
class Common {

protected static $checker;

}
class Special extends Common {

static function setChecker( ) {
parent::$checker = new Checker();
}

function show() {
echo parent::$checker->check(); <-- error !
}
}

Special::setChecker ( );

$_SESSION['b'] = new Special();

$_SESSION['b']->show();


OK
------------------------------------------------
second page in same session:
------------------------------------------------
(after start of session with class definitions)


$_SESSION['b']->show();

Fatal error: Call to a member function check() on a non-object

on the indicated line

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация