我尝试用php显示随机网址 我写这个代码但是当我运行时我找不到页面 你能解决这个bug吗? 我的代码是
<?php
$the_array = array( "https://ikman.lk", "http://www.w3schools.com", "https://www.google.lk", "https://www.giga-rdp.ca","http://tamilfreemovies.com/", "https://actproxy.com", "https://www.webmasterworld.com", "http://stackoverflow.com" );
shuffle($the_array);
$page = $the_array[0];
$ctr =100;
if (rand (0,100) <= $ctr)
{
$control="si";
}
else {
$control="no";
}
if(($control=="si") ) {
echo '<iframe align="center" width="100%" height="100%" src="$page" frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>';
}
?>
答案 0 :(得分:2)
应为src="'.$page.'"
而不是src="$page"
<?php
$the_array = array( "https://ikman.lk", "http://www.w3schools.com", "https://www.google.lk", "https://www.giga-rdp.ca","http://tamilfreemovies.com/", "https://actproxy.com", "https://www.webmasterworld.com", "http://stackoverflow.com" );
shuffle($the_array);
$page = $the_array[0];
$ctr =100;
if (rand (0,100) <= $ctr)
{
$control="si";
}
else {
$control="no";
}
if(($control=="si") ) {
echo '<iframe align="center" width="100%" height="100%" src="'.$page.'" frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>';
}