简体   繁体   中英

Trying to use [] to get value of parameter

I'm trying to get the value of some URL parameters in PHP and can't seem to get [] to detect this in the URL.

This works:

  <?php if ($params['sms_banner'] === 'true') { ?><div id="sms-banner-legacy"> SMS Banner </div><?php } ?>

This doesn't work:

  <?php if ($params['payday[sms_banner]'] === 'true') { ?><div id="sms-banner-legacy"> Legacy SMS Banner </div><?php } ?>

When I go to http://someurl.com/page?payday[sms_banner]=true it should then show the <div> on the page, but instead it can't pick up the value.

当您在url中传递数组时,可以使用来获得相同的值

$_GET['payday']['sms_banner']

php将该语法转换为数组键值,请尝试$_GET['payday']['sms_banner']params['payday']['sms_banner']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM