开发者

Include files in php showing error

I am having a folder called "db". where it contains 3 files which calls from the mail file "con开发者_如何学编程nect.php".

I created a new file in root directory and wrote a function

include "db/connect.php");
echo $connstring;

Here I am not getting any output, the $connstring is defined in another file in "db" folder named as "config.php" which is included in beginning of the "connect.php"


You have written wrong code for include function.

You should try this,

include ("db/connect.php");
echo $connstring;


I exactly was looking hot to include the files from different directories correctly.

This is how I got the code to achieve this from one of the project on Zend.

set_include_path( dirname(dirname(dirname(dirname(FILE)))) . DIRECTORY_SEPARATOR . 'library' );

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜