|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-12-08 16:12 UTC] iliaa@php.net
[2003-01-02 18:39 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 00:00:02 2025 UTC |
The following script creates a class which should become a class for session-handling <?php class my_sess { var $const = 0; function my_sess () { echo 'Constructor'."\n"; echo (++$this->const)."<br>\n"; session_set_save_handler ( array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc') ); session_start (); } function open () { echo 'open'."\n"; echo (++$this->all)."<br>\n"; } function close () { echo 'close'."\n"; echo (++$this->all)."<br>\n"; } function read () { echo 'read'."\n"; echo (++$this->all)."<br>\n"; } function write () { echo 'write'."\n"; echo (++$this->all)."<br>\n"; } function destroy () { echo 'destroy'."\n"; echo (++$this->all)."<br>\n"; } function gc () { echo 'gc'."\n"; echo (++$this->all)."<br>\n"; } function set () { echo 'set'."\n"; echo (++$this->all)."<br>\n"; } } $session = new my_sess (); echo '------------'."<br>\n"; $session->set (); $session->set (); $session->set (); echo '------------'."<br>\n"; session_write_close (); ?> If you run this script you get the following output: --------------------------------------------------------- Constructor 1 Warning: Cannot send session cache limiter - headers already sent (output started at /data/here/htdocs/versuch2.php:6) in /data/here/htdocs/versuch2.php on line 16 open 1 read 2 ------------ set 3 set 4 set 5 ------------ write 3 close 4 ------------------------------------------------------- whereas you would expect -------------------------------------------------------- Constructor 1 Warning: Cannot send session cache limiter - headers already sent (output started at /data/here/htdocs/versuch2.php:6) in /data/here/htdocs/versuch2.php on line 16 open 1 read 2 ------------ set 3 set 4 set 5 ------------ write 6 close 7 -------------------------------------------------------- It seems like there are two instances of the class hanging around. But how they relate to each other is a mystery.