php var_export读写实例类
<?php //php教程 var_export读写实例类 class user { var $filepath; function __() { $this->filepath = "d:/www.phprm.com/group/"; } function cache() { $array = $this->db->select('select group_id,group_name from group', 'hashmap'); $fp = fopen($this->filepath, 'w'); fputs($fp, '<?php return ' . var_export($array, true) . ';?>'); fclose($fp); } function getVar_export($value) { $array = require ($this->filepath); foreach ($array as $key => $v) { if ($key == $value) { $selected = ' current option'; } else { $selected = ''; } $html.= '<option value="' . $key . '"' . $selected . '>' . $v . '</option>'; } return $html; } } //使用实例方法 $g = new user(); if (intval($_GET['iscreate'])) { $g->cache(); } else { $g->getVar_export('vv'); }
教程地址:http://www.phprm.com/code/02496253b66d66ca613a2f19ea40c22e.html
欢迎转载!但请带上文章地址^^