我正在尝试制作一个数组,其中包含给定一天中从0000到2300的所有预定节目。在我的虚拟服务器上测试时,如果我的数组包含0800和0900的变量,它会给我一个500错误;当我删除它们时,站点加载正常。我是不是遗漏了什么?
当我尝试不使用0800和0900行时,它运行得很好。当我尝试仅使用这两行代码(或者其中一行或另一行)时,它拒绝加载。
<?php
$schedule = array(
dotw => "Thursday",
0000 => "Good Night Owl (Books)",
0100 => "After Midnight",
0200 => "It Makes a Difference",
0300 => "Special Interest Programs",
0400 => "Chautauqua (Non Fiction Books)",
0500 => "National Enquirer",
0600 => "Sunday New York Times (Travel)",
0700 => "Environmental Magazines",
0800 => "Kansas Newspapers",
0900 => "San Antonio Express-News",
1000 => "San Antonio Express-News",
1100 => "San Antonio Grocery Ads/Foods/Recipes",
1200 => "USA Today",
1300 => "Famous and Infamous",
1400 => "Book Potpourri",
1500 => "Smithsonian",
1600 => "Acclaimed Books",
1700 => "Commentary",
1800 => "New York Times",
1900 => "San Antonio Express-News",
2000 => "San Antonio Express-News",
2100 => "San Antonio Grocery Ads",
2200 => "USA Today",
2300 => "Evening Odyssey"
);
?>发布于 2019-06-15 12:26:01
您正在使用整数作为数组的键。以零开头的整数(如0700)被视为八进制数(即以8为基数),数字8和9在八进制数中无效,因此出现错误。
一种解决方案可能是使用插入的整数字符串:
"0800" => "Kansas Newspapers",保持一致:如果您使用此路线,请始终使用字符串。
或者,只需去掉前导零
800 => 'Kansas Newspapers',这种方法可能需要对输出进行额外的格式化。
https://stackoverflow.com/questions/56606824
复制相似问题