[EMAIL PROTECTED] wrote:
Hi there, needing some more advise, is this function correct ?

function create_object($class_name,$dir = null, $serialize = null)
        {
                        $dir ? $dir = $dir."/" : $dir = "";
                        require_once("".CLASS_PATH.$dir.$class_name.".php");
                        if ($serialize) {
                            if (!isset($_SESSION[''.$class_name.''])) {
                                        $class = new $class_name;
                                $_SESSION[''.$class_name.''] = serialize
($class);
                            }
                                return unserialize($_SESSION
[''.$class_name.'']);
                        } else {
                                return new $class_name;
                        }
        }

i needed to serialize and unserialize or else all hell broke loose.

Let me know Thanks.

Dan

If your goal is to store certain objects in sessions and some not, then this should be fine. Just be sure that you intend to have only one instance of the objects you want to serialize, or hell can still break loose :)


Jason

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to