I have recently converted my site to HTTPS and have discovered
that “phpinfo()” does not work with this configuration.
As my host has unsupported php installed - ( 5.5.7 ) and has
promised to upgrade it in the near future, I need to make
regular checks on this assertion.
I know that I could disable the SSL and then check, but that process
would be an absolute pain in the arse.
Are there htaccess or other methods that would resolve this problem?
Try this instead which hopefully will override the phpinfo() settings and show errors and warnings:
<?php
ini_set('html_errors', '1');
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(-1);
phpinfo();
// DO NOT USE CLOSING PHP TAG BECAUSE IT MAY PRODUCE ERRORS
Edit:
You could also use this site to check .htaccess is working correctly.
I am glad it worked, it looks as though your service provider is being super careful.
Are you just curious about the phpinfo() results or require specific information? If the latter then there may be other means of obtaining the information.
[quote]
Are you just curious about the phpinfo() results or require specific information?
[/quote]
Yes it is the latter.
[quote]As my host has unsupported php installed - ( 5.5.7 ) and has
promised to upgrade it in the near future, I need to make
regular checks on this assertion.
[/quote]
The phpinfo() used to give the server’s installed version right at beginning.
This is really all that I require.
Is there an alternative method to ascertain the installed version?
I agree that exposing that information can be a security risk. IMHO, instead of not exposing the fact that a site has a vulnerability it would be better to upgrade / reconfigure so a known vulnerabilitiy doesn’t exist.
In any case, phpinfo is kind of like a “get everything at once” function. It might still be possible to put together your own version of a phpinfo getting the individual information you’re interested in. Tedious, but hopefully only a one time job. eg.
<?php
if ( function_exists('phpversion') ) {
echo phpversion();
} else {
echo 'phpversion does not exist';
}
if ( function_exists('get_loaded_extensions') ) {
print_r( get_loaded_extensions() );
} else {
echo 'get_loaded_extensions does not exist';
}
etc. similar with ini_get() for individual settings. And you could put the strings into arrays to reduce repetitive if else code.
Just be careful about what you wish for. There are several bc breaks (aka fixes) between 5.6 and 7.2. Especially the count function. Make sure you thoroughly test your code before the update.
if you see a -1, PHP 7 is running.
If you see an error, PHP 5 is running.
If you see the code, PHP is not running.
If you see absolutely nothing, PHP 5 is running and your host has turned off error reporting.
(Simplest version check - find a difference between versions, and run the command. In this case, the ‘spaceship operator’.)
Grab the lines out of @John_Betong’s post above, see if you can force PHP into spitting the errors out. Probably an unnecessary step (“Until you see a -1, PHP isnt running version 7”), but not bad practice anyway