note 55742 added to language.pseudo-types

From: Date: Fri, 12 Aug 2005 01:17:36 +0000
Subject: note 55742 added to language.pseudo-types
Groups: php.notes 
Request: Send a blank email to php-notes+get-93474@lists.php.net to get a copy of this message
This's a useful example about callback, Look at the session_set_save_handler function. From: http://www.zend.com/zend/spotlight/code-gallery-wade8.php <?php /* Create new object of class */ $ses_class = new session(); /* Change the save_handler to use the class functions */ session_set_save_handler (array(&$ses_class, '_open'), array(&$ses_class, '_close'), array(&$ses_class, '_read'), array(&$ses_class, '_write'), array(&$ses_class, '_destroy'), array(&$ses_class, '_gc')); /* Start the session */ session_start(); class session { /* Define the mysql table you wish to use with this class, this table MUST exist. */ var $ses_table = "sessions"; /* Change to 'Y' if you want to connect to a db in the _open function */ var $db_con = "Y"; /* Configure the info to connect to MySQL, only required if $db_con is set to 'Y' */ var $db_host = "localhost"; var $db_user = "username"; var $db_pass = "password"; var $db_dbase = "dbname"; /* Create a connection to a database */ function db_connect() { ............ } /* Open session, if you have your own db connection code, put it in here! */ function _open($path, $name) { ............. } /* Close session */ function _close() { .............. } /* Read session data from database */ function _read($ses_id) { ................. } /* Write new data to database */ function _write($ses_id, $data) { ........... } /* Garbage collection, deletes old sessions */ function _gc($life) { ............ } } ?> ---- Manual Page -- http://www.php.net/manual/en/language.pseudo-types.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55742 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55742&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55742&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55742&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55742&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55742&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55742&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55742&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93474) next »