开发者

How can i make a path file in php

I was wondering how can I make an path file in php? For example I would like to have a pointer file in the root folder that points to the folder where the php script are held.

I tried something like this, but it does开发者_JS百科 not work.

path.php (is in the root file eg. htdocs/project1/week5)

$path = "/project1/week5/php";

set_include_path(get_include_path() . PATH_SEPARATOR . $path);

alert.php (is in the root file eg. htdocs/project1/week5)

include("path.php");
include("AlertFormAction.php");

AlertFormAction.php (is in htdocs/project1/week5/php)

What am I doing wrong? Could somebody be so kind and show me how it is supposed to be done? Thank you.


Your $path variable contains an absolute path that in most likelihood, does not exist.

Paths in PHP are local (to the server) filesystem paths. At a guess, I'd say you want to try

$path = '/htdocs/project1/week5/php';

As the include path "php" seems to be relative to your path.php file, you may find this more flexible

set_include_path(implode(PATH_SEPARATOR, array(
    __DIR__ . '/php',
    get_include_path()
)));

If using PHP 5.2 or lower, replace __DIR__ with dirname(__FILE__)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜