我想使用变量inline,但遇到语法错误。
代码低于
$json_output = @file_get_contents("http://www.youtube.com/oembed?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D$v['id']");
我得到了这个错误
04fbb7d79f886667a5b215427ff1f592第12行出现致命错误异常:语法错误,意外的"(T_ENCAPSED_AND_WHITESPACE),应为标识符(T_STRING)或变量(T_variable)或数字(T_NUM_STRING)
您需要重写这一行,因为您不能以当前的方式内联使用数组:
$json_output = @file_get_contents("http://www.youtube.com/oembed?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D$v['id']");
这些将起作用:
$json_output = @file_get_contents("http://www.youtube.com/oembed?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D{$v['id']}");
$json_output = @file_get_contents("http://www.youtube.com/oembed?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D" . $v['id']);