С нами с 03.04.03
Сообщения: 586
Рейтинг: 75
|
Добавлено: 30/05/06 в 20:36 |
Есть основной файл
main.php
<?
include "/dir1/file1.php";
?>
/dir1/file1.php содержит
<?
include 'configs/config.php';
?>
понятно, что в таком виде он работать не будет, т.к. исходный каталог - это каталог главного скрипта.
Можно ли сделать так, чтобы скрипт два вместе с подпапками можно было закачать в любую глубину сайта и после вызова его через инклуд он легко находил свои подпапки, откуда бы его не вызвали?
|
|
|
|
С нами с 16.04.05
Сообщения: 754
Рейтинг: 352
|
Добавлено: 30/05/06 в 21:47 |
Только если ты ему передаш его место. (в параметрах вызова например, или в парамитрах создания класса).
Интерпретатор php передаёт текущим путь главного скрипта. (т.е. его можно узнать. А вот "где лежу физически Я" узнать , насколько я знаю, нельзя.
|
|
|
|
С нами с 03.04.03
Сообщения: 586
Рейтинг: 75
|
Добавлено: 30/05/06 в 22:34 |
так и знал!
Спасибо.
|
|
|
|
www.phpdevs.com
С нами с 24.10.02
Сообщения: 16633
Рейтинг: 16105
|
Добавлено: 30/05/06 в 22:58 |
Код: |
__LINE__ The current line number of the file.
__FILE__ The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path whereas in older versions it contained relative path under some circumstances.
__FUNCTION__ The function name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the function name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
__CLASS__ The class name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
__METHOD__ The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive).
|
Вот эти константы тебе помогут
http://www.php.net/manual/ru/language.constants.predefined.php
|
|
Пишу на php/mysql/django за вменяемые деньги.
Обращаться в личку.
|
3
|
|
|
С нами с 03.04.03
Сообщения: 586
Рейтинг: 75
|
Добавлено: 31/05/06 в 00:35 |
Спасибо Стек!
ТО что нужно!
|
|
|
|
С нами с 16.04.05
Сообщения: 754
Рейтинг: 352
|
Добавлено: 31/05/06 в 03:13 |
Stek писал: | Код: |
__LINE__ The current line number of the file.
__FILE__ The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path whereas in older versions it contained relative path under some circumstances.
__FUNCTION__ The function name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the function name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
__CLASS__ The class name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.
__METHOD__ The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive).
|
Вот эти константы тебе помогут
http://www.php.net/manual/ru/language.constants.predefined.php |
Не знал
|
|
|
|
+ + +
С нами с 24.07.05
Сообщения: 169
Рейтинг: 88
|
Добавлено: 31/05/06 в 04:28 |
Все намного проше:
$dir=dirname (__FILE__);
так узнаеш какая текушая папка где запушен текуший скрипт
|
|
|
|
С нами с 03.04.03
Сообщения: 586
Рейтинг: 75
|
Добавлено: 31/05/06 в 10:57 |
да, так и сделал.!
|
|
|
|
Текстовая реклама в форме ответа Заголовок и до четырех строчек текста Длина текста до 350 символов Купить рекламу в этом месте! |