Translations of this page:

A very simple example for a PHP-Api that may be used as web service

/******
 * Returns the actual server-time
 * The format will be passed as string directly at the constructor (Syntax like the php-function date())
 */

class timer_api {

	var $dateFormat;

	function __construct($dateFormat) {
		$this->dateFormat = $dateFormat;
	}

	function __sleep() {
		// will be called if the object will be serialized. 
		// close open database connections and/or file-pointers here!!
 		return (array_keys(get_object_vars($this))); // This is mandatory!!
	}

	function __wakeup() {
		// will be called if the object will be unserialized, before the next method call
		// re-open closed database connections and/or file pointers
	}

	function getTime() {
		return date($this->dateFormat);
	}
}
 
en/dev/coreall/api.txt · Last modified: 10.12.2007 17:11 by kaegi
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki