欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php文件系统函数问题!

程序员文章站 2022-06-11 15:38:06
...
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;
?>

相关标签: php