【发布时间】:2015-05-17 04:27:09
【问题描述】:
我正在运行一个脚本来根据国家/地区代码重定向用户,现在我得到的响应是
Parse error: syntax error, unexpected ',' in /home2/mcp/public_html/redirect/index.php on line 15
这是第 15 行:$country_codes = 'US', 'CA', 'UK', 'AU', 'NZ', 'ZA', 'NL';
在这里使用:
if (in_array($var_country_code, array($country_codes))) {
当删除第 15 行并将其添加到 $country_codes 现在所在的位置时,给我:
if (in_array($var_country_code, array('US', 'CA', 'UK', 'AU', 'NZ', 'ZA', 'NL'))) {
效果很好。
任何看到错误的人? 如果您需要更多代码,请告诉我:)
谢谢!
顺便说一句,使用 GeoIP 插件。
【问题讨论】:
-
你打算对第 15 行做什么,设置一个国家代码数组?
-
是的,这样做更利于用户友好