时间:2021-07-01 10:21:17 帮助过:4人阅读
我要在1.php上怎么写才能在log.txt上$msg里输出的是person.php的结果,就是把那个('调入文件成功')改为那个person.php的结果
//1.php
function writeLog($msg){
 $logFile = 'log.txt';
 date_default_timezone_set('Asia/Chongqing');
 $msg = date('Y-m-d H:i:s').' >>> '.$msg."\r\n";
 file_put_contents($logFile,$msg,FILE_APPEND );
 require_once('person.php');
}
 writeLog('调入文件成功');
?>
//person.php
class Person{ 
   public $name; 
   public $age; 
   function  construct($name,$age){
     $this->name =  $name;
     $this->age = $age;
   }
   function show() {
     echo "my name is ".$this->name."  ";
   }
}
$sxd=new Person(); 
$sxd->name="sxd";
$sxd->age=22; 
$sxd->show(); 
echo "age is ".$sxd->age; 
?>