【发布时间】:2023-10-24 01:01:02
【问题描述】:
我正在尝试解决这个问题,我想从变量或'http://vine.co/v/' 旁边的任何 php 代码中回显信息 line 3 有人可以帮助我吗?
我的代码:
<?php
$vine = file_get_contents('http://vine.co/v/', false, $test);
$test = "haiKqBFA9Yw";
preg_match('/property="og:image" content="(.*?)"/', $vine, $matches);
$url = $matches[1];
$url = str_replace( 'https://', 'http://', $url );
$url = str_replace( 'versionId=', '', $url );
$img = $url;
$url = substr($img, 0, strpos($img, "?"));
echo $url;
它只是返回 $test 而不是定义的变量。
【问题讨论】:
-
根据文档,
file_get_contents中的第三个参数需要是资源。检查第四个例子:php.net/manual/en/function.file-get-contents.php -
好的,谢谢您的帮助。对于那些投反对票的人,我对 php 还是很陌生,我确实研究了很多,只是需要帮助理解。
标签: php file-get-contents