Php 按函数列出的标题失败-oop
这就是我在学习了OOP之后如何在OOP中构建页面的方法 这就是我想要的Php 按函数列出的标题失败-oop,php,Php,这就是我在学习了OOP之后如何在OOP中构建页面的方法 这就是我想要的h1的正确标题和前面的标题 但我把它放在头版我得到了一个错误: 在我的错误日志中: [20-Apr-2014 01:17:16欧洲/柏林]PHP致命错误:使用$this 当不在中的对象上下文中时 /第17行的home/jesperbo/public_html/blabla.com/index.php index.php <?php include("inc/incphp-f.php"); ?> <!--- m
h1的正确标题和前面的标题
但我把它放在头版我得到了一个错误:
在我的错误日志中:
[20-Apr-2014 01:17:16欧洲/柏林]PHP致命错误:使用$this
当不在中的对象上下文中时
/第17行的home/jesperbo/public_html/blabla.com/index.php
index.php
<?php
include("inc/incphp-f.php");
?>
<!--- more code her --->
<title>
<?php
$this->indextitle;
?>
</title>
<!--- More code her --->
它为什么会犯所描述的错误?错误说明:
[20-Apr-2014 01:17:16 Europe/Berlin]PHP致命错误:当
不在中的对象上下文中
/第17行的home/jesperbo/public_html/blabla.com/index.php
当不在类的范围内时,您正试图使用$this
。那是行不通的。只能在类结构本身中使用$this
。请在index.php中尝试以下操作:
<?php
include("inc/incphp-f.php");
$mebe_class = new mebe();
?>
<!--- more code her --->
<title>
<?php
$mebe_class->indextitle;
?>
</title>
<!--- More code her --->
这里的主要区别是我通过$mebe_class=new mebe()实例化这个类
然后使用它通过$mebe\u class->indextitle调用indextitle
值代码>现在似乎只是页面的url
<?php
include("inc/incphp-f.php");
$mebe_class = new mebe();
?>
<!--- more code her --->
<title>
<?php
$mebe_class->indextitle;
?>
</title>
<!--- More code her --->