Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- */
- public function phpize_var($var, $intend = false)
- {
- $php = '';
- switch ( gettype($var) )
- {
- case 'boolean':
- $php .= $var === true ? 'true' : 'false';
- break;
- case 'integer':
- case 'double':
- $php .= $var;
- break;
- case 'string':
- $php .= "'" .
- str_replace("'", "\\'", $var) .
- "'";
- break;
- case 'object':
- $php .= '(object)';
- case 'array':
- $php .= 'array(' . ($intend ? "\n" : '') ;
- foreach ($var as $key => $value)
- {
- $php .= $this->phpize_var($key, $intend) .
- ' => ' .
- $this->phpize_var($value, $intend) .
- ', ';
- if ($intend)
- $php .= "\n";
- }
- $php .= ')';
- break;
- case 'NULL':
- $php .= 'NULL';
- break;
- case 'resource':
- default:
- }
- if ($intend)
- $php = str_replace("\n", "\n ", $php);
- return $php;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement