我遇到一个基本问题,这实际上是一个入门问题,文档没有帮助!我的html根目录中包含以下内容的index.php,其中包含
<html>
<head>
<title>PHP Spike</title>
</head>
<body>
<?php
include __DIR__ . 'testInclude/data.php';
$dataObj = new testClass;
$data = $dataObj->GetData();
echo "$data"
?>
</body>
</html>
在名为testInclude的子文件夹中,我有一个名为data.php的文件,其中包含
<?php
class testClass
{
public function GetData()
{
return "Hello World";
}
}
?>
主页是渲染页面(显示标题,如果添加html则可以,但是没有任何帮助。有人可以指出我做错了吗?
谢谢
Ĵ
更改此行:
include __DIR__ . 'testInclude/data.php';
对此:
include __DIR__ . '/testInclude/data.php';
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句