下面这段代码
如果我想再添加一个跳转 比如id为1的跳转到1.html该怎么做
求大神帮忙解决,跪谢~
<?php
if($obj[type_id]==32){
?>
<script>window.location.href="/index.php/vodshow/32-----------.html"</script>
<?php
}
?>
下面这段代码
如果我想再添加一个跳转 比如id为1的跳转到1.html该怎么做
求大神帮忙解决,跪谢~
<?php
if($obj[type_id]==32){
?>
<script>window.location.href="/index.php/vodshow/32-----------.html"</script>
<?php
}
?>
你应该是想跳转到把 32 替换为 $obj['type_id'] 对应值的链接?
PS: 数组键名要加引号, 否则 type_id 会首先被当成 PHP 常量,无法找到这个常量时才把它当成字符串的 type_id.
<?php
if(isSet($obj['type_id']) && is_scalar($obj['type_id'])){
?>
<script>window.location.href="/index.php/vodshow/<?php echo $obj['type_id']; ?>-----------.html"</script>
<?php
}
?>
把 32 改成 1 就可以了。
?>
<?php
if($obj[type_id]==1){
?>
<script>window.location.href="/index.php/vodshow/1-----------.html"</script>
<?php
}
?>
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
3 回答2.3k 阅读✓ 已解决
3 回答2.1k 阅读✓ 已解决
直接把
$obj['type_id']
传到里面就行了