Simply, I want to get $_SERVER['DOCUMENT_ROOT']
from the command line using PHP.
The PHP docs state:
You may or may not find any of the following elements in $_SERVER. Note that few, if any, of these will be available (or indeed have any meaning) if running PHP on the command line.
Is there a known alternative to achieve the result? Apologies in advance if this is a duplicate, but I can't find anything on this specific question.
You can use:
$pwd = getenv('PWD'); // Current directory
$home = getenv('HOME'); // Home user directory
You can see more details in this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With