Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中将值(包括空格)传递到另一个页面_Php_Url_Parameters - Fatal编程技术网

在PHP中将值(包括空格)传递到另一个页面

在PHP中将值(包括空格)传递到另一个页面,php,url,parameters,Php,Url,Parameters,我试图通过url将id和用户名传递到下一页,如果用户名没有像“username”这样的空格,那么它就可以工作。但是,如果有像“username”这样的空格,只有在空格传递到下一页之前的名称 这是我的密码: <td> <?php echo '<a href=selectedCustomer.php?user_name='.$user["username"]. "&user_id=" . $user["id"] . '>' . $user["userna

我试图通过url将id和用户名传递到下一页,如果用户名没有像“username”这样的空格,那么它就可以工作。但是,如果有像“username”这样的空格,只有在空格传递到下一页之前的名称

这是我的密码:

<td>
    <?php echo '<a href=selectedCustomer.php?user_name='.$user["username"]. "&user_id=" . $user["id"] . '>' . $user["username"] . '</a>'; ?>
</td>

首先需要
urlencode()
参数:

<?php 
echo '<a href=selectedCustomer.php?user_name='.urlencode($user["username"]). "&user_id=" . $user["id"] . '>' . $user["username"] . '</a>'; 
?>

爱你的伴侣!