复制代码 代码如下:
/**
* PHP implements var_export(); function
*/
$arr = array("1","2","3");
$arr1 = array('a'=>NULL,'b'=>array('1'=>3));
var_export($arr);
//var_export($arr1);
function varExport($arr){
$ret = "array( ";
foreach($arr as $k=>$v){
$ret .= (is_numeric($k) ? $k : "'".$k."'");
$ret .= ' => ';
$_type = strtolower(gettype($v));
switch($_type){
case 'integer':
$ret .= $v." ,";
break;
case 'array':
$ret .= varExport($v).',';
break;
case 'null':
$ret .= "NULL ,";
break;
default:
$ret .= "'".$v."',";
break;
}
}
$ret .= " )";
return $ret;
}
//echo varExport($arr);
echo varExport($arr);
//bool is_numeric ( mixed $var )如果 var 是数字和数字字符串则返回 TRUE,否则返回 FALSE
//故不能用 is_numeric 验证是否为int类型。。。
?>
http://www.bkjia.com/PHPjc/327727.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327727.htmlTechArticle复制代码 代码如下: ?php /*** PHP implements var_export(); function*/ $arr = array("1","2","3"); $arr1 = array('a'=NULL,'b'=array('1'=3)); var_export($arr); //var_export($arr1); f...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn