php - 如何将 $destination 添加到 file_get_contents
问题描述
我想在 file_get_contents 的 url 中添加 $destination
$content = file_get_contents('https://googleapis.com/json?destinations=New+York+City,NY&units=imperial&origins=&key=AIzaSyDK4HhNWMzdCN5zDOJJI61BFJlKwhvpe4c');
至
$content = file_get_contents('https://googleapis.com/json?destinations=$destination&units=imperial&origins=&key=AIzaSyDK4HhNWMzdCN5zDOJJI61BFJlKwhvpe4c');
解决方案
要评估字符串中的变量,您必须使用双引号而不是单引号。
推荐阅读
- rpmbuild - 寻找简单的 noarch rpm 规范文件
- java - 使用带有执行程序通道的拆分器时,xslt 转换器模板中的间歇性问题
- java - 如何获得数组的绝对数?
- php - Facade\Ignition\Exceptions\ViewException 试图在 index.blade.php 中获取非对象的属性“名称”
- python - numpy.arr((...)) 和 numpy.arr([...]) 之间的区别
- c - 快速排序跳过一个元素
- dbt - 运行 dbt 时出现“目标未定义”错误
- javascript - Redux 仅在 Refresh 后无法在特定 Route 中工作
- r - 如何参数化分段回归系数以表示以下间隔的斜率(而不是斜率的变化)
- c++ - 检测特定的 C++ 类型是否有成员,不包括继承的成员