0

我最近更改了我的服务器代码不再工作,而在我的旧服务器上它工作得很好。

<?php
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL | E_STRICT);

$myid = "110988448104041785223";
$plus = file_get_contents("http://plus.google.com/$myid/plusones");
$match = array(); 
preg_match('/<div aria-hidden="true" class="BT"><a href="(.*?)"/',$plus,$match);
$data['url'] = $match[1];
echo strtolower($data['url']);
?>

Reurn:未定义的偏移量:1 in .... 在第 9 行

我已经在 .htaccess 中添加了这个(我不知道这是否有必要):

php_value magic_quotes 0
php_flag magic_quotes Off
php_value magic_quotes_gpc 0
php_flag magic_quotes_gpc Off
php_flag allow_url_include On

PHP 版本 5.2.17 - 旧服务器工作正常;和 PHP 版本 5.3.23 - 新服务器。

谢谢

4

1 回答 1

0

这意味着它没有找到匹配项,但无论如何您都在尝试访问结果数组。

你应该有这个:

if( preg_match('/<div aria-hidden="true" class="BT"><a href="(.*?)"/',$plus,$match)) {
    $data['url'] = $match[1];
    echo strtolower($data['url']);
}
else echo "ERROR: No match found!";
于 2013-04-23T18:35:56.363 回答