我想在另一个字符串中使用一个字符串,如下所示:
$url = " http://www.sample.com/index.php?nr= $string[0]";
我应该如何在最后插入这个字符串?
作为您的问题的解决方案,请尝试执行以下代码片段。
您需要使用点运算符(。)在 php 中连接字符串
$url = "http://www.sample.com/index.php?nr=".$string[0];
$url = "http://www.sample.com/index.php?nr={$string[0]}";
或者
$url = "http://www.sample.com/index.php?nr=" . $string[0];
就像你的例子
$url = "http://www.sample.com/index.php?nr=$string[0]";