【php开源代码栏目提醒】:网学会员鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“viewstate.php”一文,供大家参考学习
<?
class CViewState
{
var $_vs;
var $_viewstate;
function __construct($_viewstate)
{
$this->_vs = array();
$this->_viewstate = $_viewstate;
$pattern = "/ *#\|# */";
$pairs = preg_split($pattern, $_viewstate);
$pattern = "/([^ ]+)=(.*)/";
foreach($pairs as $value)
{
preg_match($pattern, $value, $regs);
if(!empty($regs[1]))
{
$this->_vs[$regs[1]] = $regs[2];
}
}
//var_dump($this->_vs);
}
function GetValue($key)
{
return $this->_vs[$key];
}
function SetValue($key, $value)
{
$this->_vs[$key] = $value;
}
function ToString()
{
$vs = '#|#';
foreach($this->_vs as $key => $value)
{
$value = ($value ? $value : '');
if($key)
{
$vs .= $key . '=' . $value . '#|#';
}
}
//var_dump($vs);
return $vs;
}
}
?>