Php 为什么赢了';不回显变量?

Php 为什么赢了';不回显变量?,php,html,Php,Html,正在尝试回显$data。。。将数据发送到$citystate和$address后,它不会打印任何内容 <html> <body> <?php $zillow_id = 'X1-ZWz18i4rtwj56z_8xo7s'; //the zillow web service ID that you got from your email $search = $_GET['address']; $citystate = $_GET['citystate']

正在尝试回显
$data
。。。将数据发送到
$citystate
$address
后,它不会打印任何内容

<html>
<body>
<?php

  $zillow_id = 'X1-ZWz18i4rtwj56z_8xo7s'; //the zillow web service ID that you got from your email

  $search = $_GET['address'];
  $citystate = $_GET['citystate'];
  $address = urlencode($search);
  $citystatezip = urlencode($citystate);

  $url = "http://www.zillow.com/webservice/GetSearchResults.htm?zws-id=$zillow_id&address=$address&citystatezip=$citystatezip";

  $result = file_get_contents($url);
  $data = simplexml_load_string($result);

  echo $data->response->results->result[0]->zpid;

?>

<form action="index.php" method="post">
Address: <input type="text" name="address"><br>
City, State, ZIP: <input type="text" name="citystate"><br>
<input type="submit">
</form>
</body>
</html>

响应->结果->结果[0]->zpid;
?>
地址:
城市、州、邮政编码:

如果有一个WP插件也能做到这一点,那就太好了。但我还是很好奇。

如果数据错误,API不会返回任何数据,所以您必须在URL中添加正确的参数

检查此链接-请尝试下面的url 它返回数据并显示zpid

结果:48749425


在这里检查zillow API完整数据-

什么是
$data
?Do
var\u dump($data)地址=?citystate=?我很确定有两件事,一是你禁用了错误。2$data不包含您认为它包含的值。我得到错误:city/state/ZIP参数无效或丢失,因此表单没有提交数据,或者我将数据发送到错误的变量?address=$search no?您需要查看表单是如何提交的,然后使用$\u POST值链接到您发送的地址值。