My site is hosted on a shared host. I’m trying to setup a new development environment (when I say new, I mean that it doesn’t look like any of my previous development environment which ranges from things like a single Notepad++ to “easy” server solutions like WAMP/XAMPP … yet I’m a C#/.NET development so php is more something I casually use at home ...)
My new environment so far has:
- Windows 10 (because that’s what I use at home)
- PhpStorm.
- Php 7.3.3 VC15 x64 Thread Safe unzipped somewhere on my my hard drive.
- php.exe refered as interpreter in PhpStorm
- php_xdebug-2.7.0-7.3-vc15-x86_64.dll set has debugged in php.ini
In my php code I have
filter_input(INPUT_SERVER,'DOCUMENT_ROOT');
It returns null (or something that is empty).
When I paste it in the terminal is says:
'filter_input' is not recognized as an internal or external command, operable program or batch file.
Well, maybe that’s the type of terminal I’m expecting but the fact that it returns null is a problem.
What should I change so that it returns the same value as in my online environment?
I have tried solutions from PHP filter_input(INPUT_SERVER, 'REQUEST_METHOD') returns null?
including adding variables_order = "GPCSE" to php.ini, but it didn’t solve the problem.
Writing filter_var(getenv('DOCUMENT_ROOT')); instead but it didn’t solve the problem ...
I want to code for my online environment not to adapt my code to my development environment.
Further test 1
Running code
var_dump(realpath(dirname(__FILE__).'/../'));
if($_SERVER['DOCUMENT_ROOT'] === '')
$_SERVER['DOCUMENT_ROOT'] = realpath(dirname(__FILE__).'/../');
var_dump($_SERVER['DOCUMENT_ROOT']);
var_dump(filter_input(INPUT_SERVER, 'DOCUMENT_ROOT'));
1st var_dump shows correct value. 2nd var_dump shows correct value. 3rd var_dump shows string(0) "". I'm not quite sure how $_SERVER and INPUT_SERVER are related though.
This will see if your server can parse the correct information from INPUT_SERVER and INPUT_ENV. If the first var_dump does not show the "DOCUMENT_ROOT" variable, then the filter_input function won't either.