Source Rally PHP Community Scripts .. Sign up .. Login
Use this script to create objects dynamicly with PHP.
LGPL license
Access: Public      Tags: php, object, classes
Add to favourites       Subscribe comments       Copy code       Bookmark
<?php
/*
$unknowObjectType = newObject($className);
*/
function newObject($className)
{
    
$origClassName $className;
    
$className preg_replace('/[^A-Za-z0-9_]/','',$className);
    if(
$origClassName!=$className)
    {
        throw new 
exception("newObject() error illegal $className.",1);
    }
    
$object = new $className;
    return 
$object;
}
?>
Add to favourites       Subscribe comments       Copy code       Bookmark
Sign up to add your own comment here!

Shared by:

regin

Mail user Add to friends
All user contributed content is available under the unless specified otherwise.
Remaining copyrights Regin Gaarsmand 2006-2008
About www.SourceRally.net