Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/04/2009, 21:09
ivanber
 
Fecha de Ingreso: octubre-2008
Mensajes: 76
Antigüedad: 15 años, 6 meses
Puntos: 3
Problemas factory.class.php

HOLA BUENAS NOCHES A TODOS.. RECURRO AQUI PARA SOLICITAR INFORMACION SOBRE EL SIGUIENTE TEMA POR QUE DEBIDO A QUE TENGO QUE CAMBIAR DE VERSION DE PHP 4 A PHP 5 Y YA TENGO MI SITIO WEB ARMADO Y ME DA EL SIGUIENTE PROBLEMA LA CLASE FACTORY.CLASS.PHP ESTA CLASE SE ENCARGA DE INSTANCIAR CADA METODO Y AHORA ME TIRA ERROR PARA ESTA VERSION DE PHP POR FAVOR SI ALGUIEN ME PUEDE DAR UNA AYUDA LO AGRADECERIA..
ESTA ES LA CLASE
<?php

class Factory {

var $sufijo = '.class.php';
var $arr_lib_dir = array( '/home/jokerage/public_html/lib/');

function Factory ( $class, $path = null ) {
if ( empty($path) ) {

foreach ( $this->arr_lib_dir as $value ) {
if ( $this->_IsValid($class, $value) ) {
$path = $value;
break;
}
}
if ( empty($path) ) {
die('No se puede encontrar el archivo de la clase en los path especificados');
}
}
if ( $this->_IsValid($class, $path) ) {
if ( !class_exists($class) ) require_once $path.$class.$this->sufijo;
if ( class_exists($class) ) {
$args = '';
$num_args = func_num_args();
if ( $num_args > 2 ) {
$lista_args = func_get_args();
for ($i = 2; $i < $num_args; $i++) {
if ( is_array($lista_args[$i]) ) {
$args .= 'array('.$this->_arr2str($lista_args[$i]).'),';
}
else {
$args .= '"'.$lista_args[$i].'",';
}
}
$args = rtrim($args, ',');
}
unset(this);
$this = eval("return new $class($args);");//EN ESTA LINEA TIRA EL ERROR

}
else {
die('No se puede incluir la clase');
}
}
else {
die('No se puede encontrar el archivo de la clase');
}
}


function _IsValid($class, $path) {

if ( is_file($path.$class.$this->sufijo) ) {
return true;
}
}

function _arr2str($array){
$line = "";
foreach($array as $key => $value){
if(is_array($value)){
$value = "array (". $this->_arr2str($value) . ")";
}
else {
$value = "'".$value."'";
}
if (is_numeric($key)) {
$line .= "," . $key;
}
else {
$line .= ",'" . $key. "'";
}
$line .= "=> ". $value;
}
$line = substr($line, 1);
return $line;
}


}
?>