Home  >  Article  >  Backend Development  >  如果输出等号前变量,该如何解决

如果输出等号前变量,该如何解决

WBOY
WBOYOriginal
2016-06-13 13:44:40967browse

如果输出等号前变量
a.php $r1='xxx';
在b.php中引用a.php
在b.php中传递过来的参数id=1

id的值和a.php中的$r后面值一样
怎样在b.php中输出a.php中的$r[$id]的内容

------解决方案--------------------

PHP code
<?php $r1='hello world';

$id=1;
$r='r'.$id;
echo $$r;
?> <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn