Home / Forums / Basel support forum / PHP Warning: Illegral string offset
Home › Forums › Basel support forum › PHP Warning: Illegral string offset
PHP Warning: Illegral string offset
- This topic has 8 replies, 2 voices, and was last updated 9 years, 1 month ago by
Artem Temos.
-
AuthorPosts
-
May 17, 2017 at 12:45 pm #13942
denisyanParticipantHello Artem, found one thing in php-error.log
bunch of PHP Warnings for functions.php line 1092
screenshot attachedAttachments:
You must be logged in to view attached files.May 17, 2017 at 2:12 pm #13950Hi,
Could you please send us a line of code related to the error?
Thank you
May 18, 2017 at 1:39 am #13990
denisyanParticipantsure, that line 1092 causing errors
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;that block about nginx
// **********************************************************************// // ! It could be useful if you using nginx instead of apache // **********************************************************************// if (!function_exists('getallheaders')) { function getallheaders() { $headers = ''; foreach ($_SERVER as $name => $value) { if (substr($name, 0, 5) == 'HTTP_') { $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; } } return $headers; } }May 18, 2017 at 1:52 am #13992
denisyanParticipantgoogled that Currently on PHP7 getallheaders does not work on nginx under FastCGI
can you help with hook to remove this function? thanks
May 18, 2017 at 6:07 am #14004Hi,
So without this function, it works correctly?
May 18, 2017 at 9:23 am #14011
denisyanParticipanti don’t know 🙂
tried to remove it – site breaks, so i dont’ know what to do.get you all information.
this line adds whole bunch of error by EACH visit to the log fileMay 18, 2017 at 9:31 am #14012Try to add the following code snippet to the functions.php file in the child theme
function getallheaders() { $headers = ''; foreach ($_SERVER as $name => $value) { if (substr($name, 0, 5) == 'HTTP_') { $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5))))); if( isset( $headers[$key] ) ) $headers[$key] = $value; } } return $headers; }Regards
May 18, 2017 at 9:33 am #14013
denisyanParticipantThanks! It worked, checked php-error.log – those warnings are gone
May 18, 2017 at 9:34 am #14014Glad to hear that 🙂
-
AuthorPosts
- You must be logged in to create new topics. Login / Register