I am using this chat: http://www.phpfreechat.net/
I place it inside a folder called chat
and when it's run, everything looks good. But if I try to include it in another file one folder up, it will say something like:
Strict Standards: Non-static method pfcGlobalConfig::Instance() should not be called statically, assuming $this from incompatible context in /home/brianl/repo/video_server/sfproject/app开发者_StackOverflows/frontend/modules/job/templates/chat/src/phpfreechat.class.php on line 44 .....
The files are called correctly by using
require_once dirname(__FILE__).'/pfccommand.class.php';
and there is no path error.
Any ideas? Thanks
I would check pfccommand.class.php to make sure that there are no relative includes involved in that class file. When I was first starting out programming in PHP I was stuck for 2 weeks on a relative include issue between two different pages. I solved this by using semi-static includes (like you are using with dirname(__FILE__)
in your example).
EDIT:
Well, when you know the directory structure, you can use that knowledge to build it dynamically. You just need to make sure that the files stay where they are supposed to. For example:
realpath(dirname(__FILE__) . '/..';
That right there will give you the directory, in full form, directly below the current files directory. That is what I call a dynamic directory. A static directory would be:
include_once('/var/www/website/public_html/filename.php');
which would require that the directory structure be the same EVERYTIME, and is a hassle if you ever change hosts, or need to push your files up a directory.
精彩评论