1
我试图解析一些HTML。 这是我的代码:使用PHP解析HTML时出错
xml_parse_into_struct($p, $initpage, $values);
foreach ($values as $key => $val) {
if (($val['tag'] == 'INPUT') && ($val['attributes']['name'] == 'authenticity_token')) {
$token = $val['attributes']['value'];
break;
}
}
echo $token;
与卷曲或XML解析没有问题...我知道,$值包括好吃的东西,如print_r($values)
WIL输出,除其他事项外,本:
[48] => Array ( [tag] => INPUT [type] => complete [level] => 8 [attributes] => Array ( [NAME] => authenticity_token [TYPE] => hidden [VALUE] => d76a4bec329537ac3322 ) )
当我尝试运行的代码,但是,我得到这个错误:
PHP Notice: Undefined variable: token in /media/.sda3/pjotr/scripts/tweet.php on line 49
什么是第49行? – Yellos