Home > Backend Development > PHP Tutorial > 关于PHP调去函数有关问题-

关于PHP调去函数有关问题-

WBOY
Release: 2016-06-13 12:55:03
Original
930 people have browsed it

关于PHP调去函数问题在线等--


$id =$_GET['id']; 

?>



如果是:baidu.php?id=b 那就调取b数据   如果url传输没有?id=b  那就自动默认调取a的数据 

请问上面代码该怎么修改啊


------解决方案--------------------
你说 a,b 是函数?

 
 if($id='b'){
  echo b() ;  //如果 b是字符串变量 就 echo $b;
 }else{
  echo a(); 
 }
 ?>
------解决方案--------------------
var $b="";<br />
if(!empty($_GET['id'])){<br />
   $b=$_GET['id'];<br />
} else{<br />
   $b=a;<br />
}
Copy after login

求给分!!!
------解决方案--------------------
$id = empty($_GET['id']) ? '这里是a值' : ($_GET['id']);
------解决方案--------------------
引用:
$id = empty($_GET['id']) ? '这里是a值' : ($_GET['id']);


echo $id;

可以试试效果。
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template