Home  >  Article  >  Backend Development  >  php文件系统函数问题!

php文件系统函数问题!

WBOY
WBOYOriginal
2016-06-02 11:32:10962browse

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;
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn