0

有没有办法实现以下目标?

在我的 /www/var/public_html/index.php 文件中,我有这个

<?php include('database/connect.php'); ?>

然后在/www/var/public_html/database/connect.php,我想做这样的事情

<?php

$my_path = get_path_of_current_script(); // should not be path of index.php
echo $my_path;
// should print
// /www/var/public_html/database
?>

我不想 $my_path 打印 /www/var/public_html/

有没有一个PHP函数可以做到这一点?

4

1 回答 1

6
$my_path = dirname(__FILE__);
于 2009-11-02T21:57:48.900 回答