2012-06-27 4 views
0

phpQuery를 사용하여 특정 이름의 양식을 얻는 방법은 무엇입니까?이름으로 양식 가져 오기

<form method="POST" name="example"> 
     <input type="hidden" 
... 

내 시도 :

include 'phpQuery-onefile.php'; 
//example site with this form 
$html = file_get_contents("http://www.example.com"); 

$pq = phpQuery::newDocument($html); 
$a = $pq->find("form name=example"); 

답변

2

사용이 ...

$a = $pq->find("form[name=example]"); 

Source.

2

phpQuery는 선택기 같은 같은 CSS/jQuery를 지원합니다, 그래서 이것은 당신이 원하는 무엇인가 :

$a = pq("form[name=example]"); 

참고 : 또한 변경 $pq->find

pq에 :

phpQuery::newDocumentHTML('<form method="POST" name="example">Something</form>'); 
$a = pq("form[name=example]"); 
echo $a; 

결과 : 통해 경우

Something 

, 그것은 형태의 HTML을 반환합니다.

관련 문제