开发者

The Script Path of an included PHP script?

开发者 https://www.devze.com 2022-12-10 21:24 出处:网络
Is there a way to achieve the following? In my /www/var/public_html/index.php file i have this <?php include(\'database/connect.php\'); ?>

Is there a way to achieve the following?

In my /www/var/public_html/index.php file i have this

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

And then in /www/var/public_html/database/connect.php, I want to do something like this

<?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
?>

I don't want $my_path to p开发者_C百科rint /www/var/public_html/

Is there a PHP function to do this?


$my_path = dirname(__FILE__);
0

精彩评论

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