php codigneter中的未定义变量角色

问题描述 投票:0回答:1

遇到PHP错误严重性:通知

消息:未定义的变量:角色

文件名:views / sample_list.php

行号:9

 <?php if($role[0]['sample']==1){?><a href="<?php echo site_url();?>/welcome/save_sample"><button class="btn btn-add  waves-effect waves-light" type="button">Add Sample</button></a><?php }?>
php
1个回答
0
投票

根据条件进行位置检查

<?php if((!empty($role[0]['sample']))&&($role[0]['sample']==1)){?><a href="<?php echo site_url();?>/welcome/save_sample"><button class="btn btn-add  waves-effect waves-light" type="button">Add Sample</button></a><?php }?>
© www.soinside.com 2019 - 2024. All rights reserved.