语法错误,意外(T_ENCAPSED_AND_WHITESPACE),期待标识符(T_STRING)或变量(T_VARIABLE)或数字(T_NUM_STRING)

时间:2015-12-13 22:20:18

标签: php

我想使用变量内联,但是我遇到了语法错误。

代码低于

$json_output = @file_get_contents("http://www.youtube.com/oembed?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D$v['id']");

我收到了这个错误

  

04fbb7d79f886667a5b215427ff1f592第12行中的FatalErrorException:   语法错误,意外''(T_ENCAPSED_AND_WHITESPACE),期待   标识符(T_STRING)或变量(T_VARIABLE)或数字   (T_NUM_STRING)

1 个答案:

答案 0 :(得分:2)

您将需要重写此行,因为您不能以当前的方式使用内联数组:

class ClassName { public $a = 'Stack'; public $b = ""; function __construct() { $this->b = $this->a.' Overflow'; } } $instantiate = new ClassName; echo $instantiate->b;

这些将起作用:

$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']}");

相关问题