iT邦幫忙

0

【Debug】PHP Key-Value 輸入格式錯誤

Key-value 版本兼容警告

如果key不加引號
$data=[
        john1=>1.2,
        'john2'=>1,
      ];
將出現key需更正為字串型別警告
Warning: Use of undefined constant john1 - assumed 'john1' (this will throw an Error in a future version of PHP) in 位址 on line 行號

Key-value 其他錯誤警告

如果在陣列內部誤加進tab空格
$data=[
      「Tab」'john1'=>1.2,
      「Tab」'john2'=>1,
      ];
則陣列無法識別
Parse error: syntax error, unexpected ''john1'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in 位址 on line 行號

(補充) Key-value寫法

//第1種
$data=array(
            'john1'=>'1.2',
            'john2'=>'1',
            );
//第2種      
$data=[
        'john1'=>'1.2',
        'john2'=>'1',
      ];
                

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言