English 中文(简体)
共享托管——如何将档案纳入网络根基?
原标题:Shared hosting - How to php include file below web root?

I am having trouble trying to get a file to be included into a php script. This file is stored in the root folder, which is not the actual web root, but the root directory that I have access to via the shared hosting account.

我在这一名录中创建了一个文件夹,储存了网站数据。

php_value session.save_path "/usr/home/accountname/sessions"

网络根基将存放在这一名录中:

/usr/home/accountname/public_html/domainname/

我试图做的是,确保掌握数据库连接细节的精髓,其夹象这样:

/usr/home/accountname/includes/

这是目前如何包括档案:

require_once $_SERVER[ DOCUMENT_ROOT ]. /includes/config.php ;

我已尝试这样做:

require_once $_SERVER[ PATH ]. /usr/home/accountname/includes/config.php ;

∗∗∗∗∗

这并不是因为网页上出现空白,这意味着<代码>config.php中界定的变量。 由于该网页没有列入,因此并不活跃。

任何人都能够提供这方面的一些信息,或向我指出解决问题的方向。 此外,将非常赞赏这方面的任何辅导或其他信息。

谢谢!

最佳回答

If the script including config.php is stored under your Web root, you can write:

require_once dirname(__FILE__) .  /../../includes/config.php ;

你是否已经尝试过?

问题回答

如果您的文字载于/usr/home/accountname/public_html/domainname/something.php,你可以使用:

require_once(dirname(dirname(dirname(__FILE__))).PATH_SEPARATOR."includes".PATH_SEPARATOR."config.php");




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签