2009-11-02 5 views
0

Existe-t-il un moyen d'obtenir ce qui suit?Le chemin de script d'un script PHP inclus?

Dans mon fichier /www/var/public_html/index.php Je possède ce

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

Et puis dans /www/var/public_html/database/connect.php, je veux faire quelque chose comme ça

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

Je ne veux pas mon_chemin de $ pour imprimer/www/var/public_html/

y at-il une fonction PHP pour le faire?

Répondre

6
$my_path = dirname(__FILE__);