php 继承包含父类的有关问题

WBOY
Release: 2016-06-13 13:28:14
Original
925 people have browsed it

php 继承包含父类的问题
子类包含父类时,我使用一个常量 include_once(_CLASS_PATH_.'父类.php')
子类在程序运行时被其他php页面引用,该页面包含有clss_path这个常量
问题是
如果我直接打开子类php的文件,会报错,问题我知道,是因为class_path没有赋值
所以在这里想问一下大家,这个问题有没有什么好的解决办法。我该如何包含父类才不会出这样的错呢?

------解决方案--------------------
你把类定义文件们放到相对网站根的固定目录中不就结了
在配置 __autoload 函数,使之能自动加载,而无需到处 include
------解决方案--------------------
放在入口文件,或者公共文件里。或者放到includepath里面

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!