我试图从主播那里获取ID。有没有办法用PHP提取它?
<a class="nav-link" href="#dpd-'.$model->idDpd->id_dpd.'" id='.$model->idDpd->id_dpd.'role="tab" data-toggle="tab">'.$model->name.'</a>
我使用DOMDocument :: getElementById来获取锚点的ID。我不确定是否有更好的方法(我使用的是Yii2框架):
ob_start();
include 'cabang.php';
$result = ob_get_clean();
$doc = new DOMDocument();
$doc -> load($result);
// We need to validate our document before refering to the id
$doc->validateOnParse = true;
$result = $doc->getElementById('$model->idDpd->id_dpd');
$query = Cabang::find()-> where(['id_dpd'=>$result])->all();
//other code goes here
上面的代码给出此错误:Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes)
为了获取目的,我指定了锚及其各自的ID。选择具有特定“ id_dpd”的锚点后,它将基于所选的锚点ID显示详细信息。是使用AJAX提取它的唯一方法吗?
我在这里做错了什么?谢谢!