我刚刚开始学习面向对象的php,并且遇到了我认为是一个非常琐碎的问题。我有两个.php文件,post.php和testPost.php像这样:
//post.php
<?php
class fileWrite{
public function postMessage($logId, $text, $username){
//If the original login form was not used then this would not be set
date_default_timezone_set('Europe/London');
$fp = fopen($logId, 'a');
fwrite($fp, $text);
fclose($fp);
}
}
?>
//testPost.php
<?php
include 'post.php';
$post = new fileWrite;
$post->postMessage("log.html", "test", "username");
?>
当我运行testPost.php时,输出为:postMessage(“ log.html”,“ test”,“ username”); ?>
任何帮助将不胜感激。
刚刚测试了您的代码,它可以很好地工作,请检查是否有错字或脚本是否具有扩展名.php
。如果不是这样,将导致输出按字面意义显示您的代码。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句