PHP Classes
elePHPant
Icontem

File: simpleexamples.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of J.B.  >  Simple Object  >  simpleexamples.php  >  Download  
File: simpleexamples.php
Role: Example script
Content type: text/plain
Description: Useless SimpleObject method usage examples
Class: Simple Object
Base class with common variable access functions
Author: By
Last change:
Date: 11 years ago
Size: 1,330 bytes
 

Contents

Class file image Download
<?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');
?>