I need to call the root directory of my project, just the root regardless of where the script is.
Finding $_SERVER['DOCUMENT_ROOT']
and good practice I want to pass this to a constant within an object using const
.
<?php
class Test{
const DIROOT = $_SERVER['DOCUMENT_ROOT'];
}
However, I get the following error:
"Fatal error: Constant expression contains invalid operations in /var/www/html/sys/php/test.php on line 3 "
If I try to declare it with pure string const DIROOT = "/exemplo";
it works. Why?