当前位置: 动力学知识库 > 问答 > 编程问答 >

syntax - how to include file from child directory in php

问题描述:

My file lies in /var/www/spywgc/adm/index.php folder .... and the file i want to include lies in var/www/spywgc/adm/rpt/lib_pivot.php

I want to include lib_pivot.php in index.php..... The lib_pivot.php interns include a file var/www/spywgc/lib_gen file.....

I wrote a syntax of in index.php file... but, it keeps giving me error....

Someone please explain me what to do.

网友答案:

Well it's hard to solve without you telling us the actual error, but this should work

include('/var/www/spywgc/adm/rpt/lib_pivot.php');

If anything you might have been missing the "/" at the start of the string

网友答案:

include('rpt/lib_pivot.php'); will work, unless there's something I'm misunderstanding.

When you call include(), and don't begin with a '/', it starts in the directory of the caller script. So if index.php is in adm/, then just progress from inside adm/ further down the path.

Section 2

If I understand this correctly (it's kind of confusing):

The lib_pivot.php interns include a file var/www/spywgc/lib_gen file

then inside of lib_pivot.php use include('../../lib_gen.php'); to come up two directories from the rpt/ directory.

网友答案:

You have no showed the include() statement that resides on line 1 inside of lib_pivot.php...thats where you error is comming from

分享给朋友:
您可能感兴趣的文章:
随机阅读: