Home Forums Basel support forum PHP Warning: Illegral string offset

PHP Warning: Illegral string offset

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #13942

    denisyan
    Participant

    Hello Artem, found one thing in php-error.log

    bunch of PHP Warnings for functions.php line 1092
    screenshot attached

    Attachments:
    You must be logged in to view attached files.
    #13950

    Artem Temos
    Keymaster

    Hi,

    Could you please send us a line of code related to the error?

    Thank you

    #13990

    denisyan
    Participant

    sure, 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; 
        } 
    } 
    #13992

    denisyan
    Participant

    googled that Currently on PHP7 getallheaders does not work on nginx under FastCGI

    can you help with hook to remove this function? thanks

    #14004

    Artem Temos
    Keymaster

    Hi,

    So without this function, it works correctly?

    #14011

    denisyan
    Participant

    i 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 file

    #14012

    Artem Temos
    Keymaster

    Try 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

    #14013

    denisyan
    Participant

    Thanks! It worked, checked php-error.log – those warnings are gone

    #14014

    Artem Temos
    Keymaster

    Glad to hear that 🙂

Viewing 9 posts - 1 through 9 (of 9 total)