将变量传递到url中

tip*_*top 2 css php parsing

好吧,我已经被困了几天...一直试图找到一个答案,关于如何将我的变量传递到php代码的url并在每次提交表单时更新url.但是,我发现的所有内容都是如何通过url传递变量...实际上并没有能够实现这个,因为我觉得我需要一个不同的解决方案.所以这里是代码,除了将$ var传递给URL并重新更新脚本以使用新URL运行之外,一切似乎都在工作.

例如,原始目前看起来像这样:

    $html = file_get_html('http://www.championselect.net/champ/{$var}');
Run Code Online (Sandbox Code Playgroud)

我希望有人在表单中输入一个条目,并且每次都要更新$ var.

所以:假设某人想要搜索"ziggs"或"jinx",他们会在表单中输入名称,表单需要更新脚本以使用新的$ var运行解析器.

非常感谢所有的帮助!!

<form action="test.php" method="post">
<input type="text" value="<?php echo $var?>" name="var" />
<input type="submit" value="Send" />
</form>
<?php

$var = $_POST['var'];
echo $var;


// Include the library to use it.
include_once('simple_html_dom.php');

// Get div from site. ... Need to implement user selected queries.

$html = file_get_html('http://www.championselect.net/champ/{$var}');

// Put all of the <a> tags into an array named $result
$result = $html -> find('h2,img[class=CS_Champ_Image],.counterName' );

// Run through the array using a foreach loop and print each link out using echo
foreach($result as $element) {
  echo $element."   ";}   

?>
Run Code Online (Sandbox Code Playgroud)

BA_*_*max 5

尝试...

$html = file_get_html('http://www.championselect.net/champ/'.$var);
Run Code Online (Sandbox Code Playgroud)

变量不会在单引号内解析