4,251
社区成员
发帖
与我相关
我的任务
分享
<?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();