首页 > 解决方案 > 如何将 $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');

标签: php

解决方案


要评估字符串中的变量,您必须使用双引号而不是单引号。


推荐阅读