无法url编码字符串

时间:2011-11-16 16:20:13

标签: php url

当我输入时:

<form method="post"  action="../Thread/thread.php?threadID=".<?php echo $threadID; ?>."&page=".<?php echo $page; ?> > 

我明白了:

http://localhost/PoliticalForum/Thread/thread.php?threadID=

如何将变量编码到url中以避免出现此类错误?

3 个答案:

答案 0 :(得分:3)

 echo('<form method="post"  action="../Thread/thread.php?threadID=' . $threadID . '&page='  . $page . '">'); 

你的报价有问题。

编辑:

$url = sprintf("../Thread/thread.php?threadID=%1s&page=%2s",$threadID,$page);
echo('<form method="post"  action="'.$url .'">'); 

http://php.net/manual/en/function.sprintf.php

答案 1 :(得分:2)

报价问题试试这个

<form method="post"  action="../Thread/thread.php?threadID=<?php echo $threadID; ?>&page=<?php echo $page; ?>" >

答案 2 :(得分:0)

你的报价错了,试试这个:

<form method="post"  action="../Thread/thread.php?threadID=<?php echo $threadID; ?>&page=<?php echo $page; ?>">