包含的PHP脚本的脚本路径?
有没有办法实现以下目标 在我的/www/var/public_html/index.php文件中包含的PHP脚本的脚本路径?,php,relative-path,Php,Relative Path,有没有办法实现以下目标 在我的/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_
<?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函数来执行此操作
$my_path = dirname(__FILE__);