0

I'm trying to make a custom .ini file to store sensitive information which I can then get using parse_ini_file. However I have some problems.

Using Azure I set up an Application Setting:

Name: PHP_INI_SCAN_DIR Value: D:\home\site\ini

It shows that its loading my custom ini file in phpinfo which I named test.ini Inside that I have...

[database_info]
;Database Information
dbUser=itstheuser
dbPassword=itsthepassword

[keys]
secretKey=aSeCreTKey

Then, in my php file I have

$ini = parse_ini_file('test.ini');
echo $ini['dbUser'];

However, this returned nothing, I tried an echo after this and that echoed fine, but the ini file did not. Note: this was using PHP 5.6.

I then updated to PHP 7.0 and I get the error...

The page cannot be displayed because an internal server error has occurred.

It seems PHP 7.0 does not like my custom ini file, because when I remove the ini file the error goes away and adding it back, brings back the error. I am unsure why this is.

So my problems are basically that I can't get my custom ini file to work, is there something I'm doing wrong?

Lewis
  • 566
  • 4
  • 21
  • `PHP_INI_SCAN_DIR` is for joining addition *PHP* configuration. It will not load unknown sections or directives (it's for php modules and their zend_parse_ini declarations). Hence `parse_ini_file` should be given the full path to the `test.ini`. Enable error_display, or look into log files. There should be a warning of sorts I'd presume. – mario Aug 25 '18 at 16:33
  • See also https://stackoverflow.com/questions/2687730/how-can-i-make-php-display-the-error-instead-of-giving-me-500-internal-server-er – mario Aug 25 '18 at 16:34
  • Mine says D:\local\Config\PHP-7.0.30\php.ini So how do i access it if that file doesnt exist for me to access – Lewis Aug 25 '18 at 16:40
  • Your `php.ini` is not really relevant. `parse_ini_file()` works independently of PHPs main configuration. Also you should really look for the real error message first. – mario Aug 25 '18 at 16:42
  • I assume I'm meant to be looking in the php_errors.log file, but in there are no errors relating to this issue, just basic errors like incorrect syntax when I was building it. – Lewis Aug 25 '18 at 17:45

0 Answers0