使用文件放置内容保存内容

发布于 2024-11-10 10:09:02 字数 330 浏览 4 评论 0原文

我正在尝试获取 google steetview 瓷砖并保存它们。但 file_get_contents 不喜欢我的网址:

这是我的代码:

$img = "http://cbk0.google.com/cbk?output=tile&panoid="+$panorama_id+"&zoom=3&x="+$i+"&y='"+$x+"'";
$url = ""+$panorama_id+"Xval"+$i.+"Yval"+$x+".jpg";


file_put_contents($url, file_get_contents($img));

i'm trying to get google steetview tiles and save them. But file_get_contents doesn't like my url:

here's my code:

$img = "http://cbk0.google.com/cbk?output=tile&panoid="+$panorama_id+"&zoom=3&x="+$i+"&y='"+$x+"'";
$url = ""+$panorama_id+"Xval"+$i.+"Yval"+$x+".jpg";


file_put_contents($url, file_get_contents($img));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笔芯 2024-11-17 10:09:02

您正在使用 + 进行串联。那不是 PHP。您需要使用点 . 运算符:

$img = "http://cbk0.google.com/cbk?output=tile&panoid=" . $panorama_id . "&zoom=3&x=" . $i . "&y='" . $x . "'"; 
$url = $panorama_id . "Xval" . $i . "Yval" . $x . ".jpg";

请参阅字符串运算符< PHP 手册中的 /a> 。

或者,使用双引号字符串时,将解析字符串内的变量。 请参阅字符串类型的手册页。

$img = "http://cbk0.google.com/cbk?output=tile&panoid=$panorama_id&zoom=3&x=$i&y='$x'"; 
$url = "${panorama_id}Xval${i}Yval${x}.jpg";

You're using + for concatenation. That's not PHP. You need the dot . operator instead:

$img = "http://cbk0.google.com/cbk?output=tile&panoid=" . $panorama_id . "&zoom=3&x=" . $i . "&y='" . $x . "'"; 
$url = $panorama_id . "Xval" . $i . "Yval" . $x . ".jpg";

See string operators in the PHP manual.

Alternatively, with double quoted strings, variables within the string will be parsed. See the manual page for the string type.

$img = "http://cbk0.google.com/cbk?output=tile&panoid=$panorama_id&zoom=3&x=$i&y='$x'"; 
$url = "${panorama_id}Xval${i}Yval${x}.jpg";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文