将值传递给php变量


Pass value to php variable

这篇文章是我上一篇文章的延续,我错过了一点,所以我开始了新的线程。我得到了上一篇文章的解决方案,我的最终代码如下:

php 中的报废代码不起作用

<?php
$html = file_get_contents("http://geoportaal.maaamet.ee/url/xgis-ky.php?ky=79401:006:0812");
preg_match_all('(<li.*?>.*?</li>)', $html, $matches);
$one=$matches[0][0];
?>
<script type="text/javascript">
function Assign() {
    document.getElementById("OutputField").value = "<?=$one?>";
}
</script>
<input id="OutputField" type="text" style="width:200px"/>
<input type="button" value="Assign Value" onclick="Assign()"/>

此外,我在末尾又添加了一个输入框,在该文本框中,我将在运行时输入我的值,所以一旦我单击按钮,文本框值将转到php变量,然后该变量将在"ky="之后赋值。我尝试了一些像POST和GET方法之类的东西,但还是错过了一些东西。

我看起来像

$html = file_get_contents("http://geoportaal.maaamet.ee/url/xgis-ky.php?ky=" + $PHPvariable);

您需要学习如何在PHP:中处理表单和表单信息

http://php.net/manual/en/tutorial.forms.php