public static function toPHPVariableString($value)
    {
		switch (gettype($value)) {
        	case "string" :
        	    $returnValue = '\''.str_replace('\'', '\\\'', str_replace('\\', '\\\\', $value)).'\'';
        		break;
        	case "boolean" :
        		$returnValue = $value ? 'true' : 'false';
        		break;
        	case "integer" :
        	case "double" :
        		$returnValue = $value;
        		break;
        	case "array" :
				$string = "";
				foreach ($value as $key => $val) {
					$string .= self::toPHPVariableString($key)." => ".self::toPHPVariableString($val).",";
				}
				$returnValue = "array(".substr($string, 0, -1).")";
				break;
        	case "NULL" :
        		$returnValue = 'null';
				break;
        	case "object" :
        	    if ($value instanceof PhpSerializable) {
        	       $returnValue = $value->__toPhpCode();
        	    } else {
        	       $returnValue =  'unserialize('.self::toPHPVariableString(serialize($value)).')';
        	    }
        		break;
        	default:
    			// resource and unexpected types
        		throw new common_exception_Error("Could not convert variable of type ".gettype($value)." to PHP variable string");
        }

        return (string) $returnValue;
    }
public static function toPHPVariableString($value)
    {
		switch (gettype($value)) {
        	case "string" :
        	    $returnValue = '\''.str_replace('\'', '\\\'', str_replace('\\', '\\\\', $value)).'\'';
        		break;
        	case "boolean" :
        		$returnValue = $value ? 'true' : 'false';
        		break;
        	case "integer" :
        	case "double" :
        		$returnValue = $value;
        		break;
        	case "array" :
				$string = "";
				foreach ($value as $key => $val) {
					$string .= self::toPHPVariableString($key)." => ".self::toPHPVariableString($val).",";
				}
				$returnValue = "array(".substr($string, 0, -1).")";
				break;
        	case "NULL" :
        		$returnValue = 'null';
				break;
        	case "object" :
        	    if ($value instanceof PhpSerializable) {
        	       $returnValue = $value->__toPhpCode();
        	    } else {
        	       $returnValue =  'unserialize('.self::toPHPVariableString(serialize($value)).')';
        	    }
        		break;
        	default:
    			// resource and unexpected types
        		throw new common_exception_Error("Could not convert variable of type ".gettype($value)." to PHP variable string");
        }

        return (string) $returnValue;
    }
public static function toPHPVariableString ( $ value ) { switch ( gettype ( $ value ) ) { case "string" : $ returnValue = '\'' . str_replace ( '\'' , '\\\'' , str_replace ( '\\' , '\\\\' , $ value ) ) . '\'' ; break ; case "boolean" : $ returnValue = $ value ? 'true' : 'false' ; break ; case "integer" : case "double" : $ returnValue = $ value ; break ; case "array" : $ string = "" ; foreach ( $ value as $ key => $ val ) { $ string .= self :: toPHPVariableString ( $ key ) . " => " . self :: toPHPVariableString ( $ val ) . "," ; } $ returnValue = "array(" . substr ( $ string , 0 , - 1 ) . ")" ; break ; case "NULL" : $ returnValue = 'null' ; break ; case "object" : if ( $ value instanceof PhpSerializable ) { $ returnValue = $ value -> __toPhpCode ( ) ; } else { $ returnValue = 'unserialize(' . self :: toPHPVariableString ( serialize ( $ value ) ) . ')' ; } break ; default : // resource and unexpected types throw new common_exception_Error ( "Could not convert variable of type " . gettype ( $ value ) . " to PHP variable string" ) ; } return ( string ) $ returnValue ; }
Returns the php code, that if evaluated
would return the value provided

@access public
@author Joel Bout, <joel@taotesting.com>
@param  value
@return string
Returns the php code that if evaluated would return the value provided