O
O
Optimus2016-10-03 10:52:57
PHP
Optimus, 2016-10-03 10:52:57

Different path depending on the method to run the script?

If I run the file through a browser (routing works, it does not open directly), then a path is needed to access the configuration file:
$dir = '../../folder/config.php';
If I run the file through cron, then in order for the configuration file to be picked up, I have to specify a completely different path:

$dir    = '../user/web/domain.ru/folder/config.php';

Is it possible to use some system variable to specify one path for both launch options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2016-10-03
Pyan @marrk2

__DIR__ constant - it stores the path to the current script, you can build on it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question