小编Ven*_*nom的帖子

file_get_contents无法正常工作?

此代码不适用于服务器.但它正在我的localhost(xampp)工作

$url = file_get_contents('http://www.site.com/');
$xhtml='|<tr style="background-color:#dddddd;">
        <td class="odd" align="left">(.+?)</td><td class="odd">(.+?)</td>
    </tr>|i';
preg_match_all($xhtml,$url,$score);
array_shift($score);
echo"<pre>";
print_r($score);
echo"</pre>";
Run Code Online (Sandbox Code Playgroud)

当我像这样更改代码时,它会打印另一个分数.因为这样有两行.它有相同的代码.顺便说一句下面的代码工作到服务器.

$xhtml='|<td class="odd" align="left">(.+?)</td><td class="odd">(.+?)</td>|i';
Run Code Online (Sandbox Code Playgroud)

我需要在代码之间取两个值.

allow_url_fopen = on
Run Code Online (Sandbox Code Playgroud)

php regex file-get-contents

15
推荐指数
3
解决办法
6万
查看次数

标签 统计

file-get-contents ×1

php ×1

regex ×1