我是一个PHP新手,我正在尝试做我认为在网站上相当复杂的操作。所以我需要你的帮助:))
我想要做的是为每个客户请求一个特定的页面,所涉及的唯一URL变量就像往常一样。
基本上我的变量先前已在脚本中设置,我想说的是;
不知何故,网址为http://site.com/index.php?image=$clientnumber
。
如果你们能给我一些关于如何做到这一点的见解,那就太棒了!
答案 0 :(得分:1)
您可以使用sprintf function执行此操作:
$url = sprintf('http://site.com/index.php?image=%s', $clientnumber);
答案 1 :(得分:1)
$new_url = "http://site.com/index.php?image=$clientnumber";
或
$new_url = 'http://site.com/index.php?image=' . $clientnumber;
答案 2 :(得分:0)
$data = array('foo'=>'bar',
'baz'=>'boom',
'cow'=>'milk',
'php'=>'hypertext processor');
echo http_build_query($data) . "\n";
结果:
富=栏&安培;巴兹=吊杆&安培;牛奶=&安培; PHP超文本= +处理器
根据您的需要:
$data = array('image'=> $clientnumber);
echo 'index.php?' . $data;
会给你:
的index.php?图像= 878787283