0

Out 公司运营大量服务器

我们使用内部脚本过滤出各种信息,前端用户会说输入邮政编码,然后它将处理一页信息中的五页列表。

注意:我们知道我们的代码可能不是最简单的,但它目前似乎可以工作,任何知道更简单方法的人请说

<?php $postcode = $_POST['postcode']; ?>

// get DOM from URL or file
$html = file_get_html('http://xx.com/en/search/records/search.pub?Surname=willi*&Location=$postcode&x=39&y=9&Page=1');
$html1 = file_get_html('http://xx.com/en/search/records/search.pub?Surname=willi*&Location=$postcode&x=39&y=9&Page=2');
$html2 = file_get_html('http://xx.com/en/search/records/search.pub?Surname=willi*&Location=sa11&x=39&y=9&Page=3'); 

我们有进一步的代码过滤掉我们的服务器结果,但是由于某种原因,当我们的一个用户将表单发布到这个脚本时,只有底部的结果纯粹是因为位置是硬编码的 - 其他的都是未知的,我们认为它没有正确地将邮政编码变量传递给网址

可能是因为 $postcode 变量已经在 $html 变量中,有没有办法解决这个问题?

谢谢

4

1 回答 1

1

字符串 beetwen 单引号 (') 不会被评估。尝试类似的东西

$html = file_get_html('http://xx.com/en/search/records/search.pub?Surname=willi*&Location='.$postcode.'&x=39&y=9&Page=1');
$html1 = file_get_html('http://xx.com/en/search/records/search.pub?Surname=willi*&Location='.$postcode.'&x=39&y=9&Page=2');

并在您的程序中使用它之前检查 $postcode 值是否有效,请

于 2011-05-30T17:15:01.750 回答