4,251
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
<?php
class test{
public $id;
public $name;
public $mobile;
public $regtime;
function __construct(){
@$conn=mysql_connect('localhost','root','123456789');
$db=mysql_select_db('design');
$res=mysql_query("select * from user where `id`=1");
$data=mysql_fetch_assoc($res);
$this->id=$data['id'];
$this->name=$data['name'];
$this->mobile=$data['mobile'];
$this->regtime=$data['regtime'];
}
function __destruct(){
mysql_query("update user set `regtime`='{$this->regtime}',`mobile`='{$this->mobile}',`name`='{$this->name}' where `id`='{$this->id}' LIMIT 1");
}
}
class Page{
function index(){
$user1 = new test();
$user1->name='tom';
$this->test();
}
function test(){
$user2= new test();
$user2 ->mobile='333333333';
}
}
$Page=new Page();
$Page->index();