Article From:https://segmentfault.com/q/1010000012143462
Question:

Apacher php-fpm linux The next log appears Cannot use a scalar value as an array error warning.

Execute the error warning line:

$notValveForKey[$key]='app='.APP_NAME.'&mod='.MODULE_NAME.'&act='.ACTION_NAME;

The following is the complete method:

function L($key,$data = array()){
    $key = strtoupper($key);
     if(!isset($GLOBALS['_lang'][$key])){
         $notValveForKey = F('notValveForKey', '', DATA_PATH.'/develop');
         if($notValveForKey==false){
           $notValveForKey = array();
         }
         if(!isset($notValveForKey[$key])){
           *$notValveForKey[$key] = '?app='.APP_NAME.'&mod='.MODULE_NAME.'&act='.ACTION_NAME;*
         }
         F('notValveForKey', $notValveForKey, DATA_PATH.'/develop');
          return $key;
     }
     if(empty($data)){
          return $GLOBALS['_lang'][$key];
     }
     $replace = array_keys($data);
     foreach($replace as &$v){
        $v = "{".$v."}";
     }
     return str_replace($replace,$data,$GLOBALS['_lang'][$key]);
}

Hope the great God helps.

Answer 0:

Before printing the wrong line, print the value of $notValveForKey, and you will know the problem.

Leave a Reply

Your email address will not be published. Required fields are marked *