Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在javascript中输入php作为url_Javascript_Php_Wordpress - Fatal编程技术网

如何在javascript中输入php作为url

如何在javascript中输入php作为url,javascript,php,wordpress,Javascript,Php,Wordpress,我想通过在脚本中使用php获得帖子缩略图 示例:(我不知道这是否有意义) 变量配置={ 海报:“ }; 您的代码似乎正确 $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); 我对jwplayer使用相同的方法 但是是否使用错误深入了解wordpress中的函数它使用JavaScript变量的数据本地化已注册的脚本。这在某种程度上不起作用吗?你只需要在PHP的最后加上分号吗?不,我不需要。很抱歉。我修正了它。

我想通过在脚本中使用php获得帖子缩略图

示例:(我不知道这是否有意义)


变量配置={
海报:“
};

您的代码似乎正确

$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
我对jwplayer使用相同的方法


但是
是否使用错误

深入了解wordpress中的函数它使用JavaScript变量的数据本地化已注册的脚本。

这在某种程度上不起作用吗?你只需要在PHP的最后加上分号吗?不,我不需要。很抱歉。我修正了它。你把分号放错地方了,它应该放在
echo$url
之后,然后你需要做的就是在Javascript中的某个地方使用
conf.poster
,谢谢,但我该怎么做呢?“它基本上忽略了命令”没有告诉我们任何事情。使用浏览器的调试工具。生成的实际JavaScript代码是什么?它究竟是如何失败的?
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );