Set value for a variable (only on editor side)
To import from other php files I usually do this:
$include = explode('public_html', dirname(__FILE__))[0] . 'include/';
include $include . 'header.php';
It works great, and prevents all the ../../../../ relative path hackery.
But PHPStorm doesn't enjoy it that much, screaming that the file doesn't exist or that prevent me from using autocomplete with structures from that file or variables. I wonder if there is a way for me to tell the editor, the $include variable always is "/var/www/site/include" or something like that.
Please sign in to leave a comment.
Nope, no such a way. Is there something wrong with using
$_SERVER['DOCUMENT_ROOT']? You can redefine it since 2018.2.5: https://youtrack.jetbrains.com/issue/WI-35064