php文件系统函数问题!
程序员文章站
2024-02-05 23:16:40
...
php
我要在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;
?>
上一篇: 渐变颜色选择器