これは私のコードです。「動作していません」と表示されます
$f = file_get_contents("http://www.google.com");
$text = htmlspecialchars( $f );
$matches = array();
preg_match('@<a.*?</a>@s', $text, $matches);
if ($matches) {
$text2 = $matches[0];
echo $text2;
}
else {
echo "Not working";
}
変数を作成した場合:
$text = '<a href="http://www.google.com">Google</a> is your best friend!';
これは何とか機能しますが、次のものから取得すると機能しません。
$text = htmlspecialchars( $f );
誰でも理由を知っていますか?