<?php # SIMPLE SIMPLEOBJECT USAGE EXAMPLES error_reporting(E_ALL); require_once('simpleobject.php'); # Normally you should extend SimpleObject class to # make something really useful $obj =& new SimpleObject(SO_STRICT); $obj->init('a','<strong>Mel Gibson movie "The Passion of The Christ"</strong>'); $obj->init('b',''); $obj->set('b','Some people hate '); $obj->append('b','object oriented scripting');
# no filters echo $obj->get('a'); echo $obj->get('b'); # htmlsafe filter: echo $obj->get('a','htmlsafe'); # sqlsafe filter (for MySQL queries): echo $obj->get('a','sqlsafe'); # two filters: striptags + sqlsafe echo $obj->get('a',array('striptags','sqlsafe'));
# register filter for all getters $obj->register_filter('striptags'); echo $obj->get('a'); # unregister filter for all getters $obj->unregister_filter('striptags'); # filters are not applied twice if you happen to call them after registering: $obj->register_filter('htmlsafe'); echo $obj->get('a','htmlsafe'); $obj->unregister_filter('htmlsafe'); # modify whole object with a single filter $obj->apply_filter('uppercase'); echo $obj->get('b'); echo $obj->get('a'); # clear all object properties $obj->init_object(); $obj->init('b'); $obj->append('b','Who wants to live forever?'); echo $obj->get('b'); ?>
|