<form class="formclass" id="loginform" method="post" onsubmit="return loginform();">
<div style="padding-bottom:5px">Username</div>
<div style="padding-bottom:5px"><input type="text" name="username" style="width:180px"></div>
<div style="padding-bottom:5px">Password</div>
<div style="padding-bottom:5px"><input type="password" name="password" style="width:180px"></div>
<div style="padding-bottom:5px"><div style="padding:5px 0px"><a href="javascript:void(0);" onclick="captchareload2();"><img src="modules/captcha/captcha.php?r=login" id="captchaimglogin" border="0"></a></div>
<script>function captchareload2(){
$("#captchaimglogin").attr('src','modules/captcha/captcha.php?r=login&x=34&y=75&z=119&?newtime=' + (new Date()).getTime());
}</script></div>
<div style="padding-bottom:5px"><input type="text" name="captcha" id="captcha_login" style="width:180px"></div>
<div style="padding-bottom:5px"><input type="submit" name="login" value="Login" class="orange"></div>
</form>===========================================
上面这段内容:1、把 <div style="padding-bottom:5px"><div style="padding:5px 0px"><a href="javascript:void(0);" onclick="captchareload2();"><img src="modules/captcha/captcha.php?r=login" id="captchaimglogin" border="0"></a></div>
<script>function captchareload2(){
$("#captchaimglogin").attr('src','modules/captcha/captcha.php?r=login&x=34&y=75&z=119&?newtime=' + (new Date()).getTime());
}</script></div>,取出来,用正则匹配2、匹配 在<form></form>里是否包含 第1点 的内容,有包含 输出真,没包含输出假=======================================我是在搞不懂了,请帮帮忙
<div style="padding-bottom:5px">Username</div>
<div style="padding-bottom:5px"><input type="text" name="username" style="width:180px"></div>
<div style="padding-bottom:5px">Password</div>
<div style="padding-bottom:5px"><input type="password" name="password" style="width:180px"></div>
<div style="padding-bottom:5px"><div style="padding:5px 0px"><a href="javascript:void(0);" onclick="captchareload2();"><img src="modules/captcha/captcha.php?r=login" id="captchaimglogin" border="0"></a></div>
<script>function captchareload2(){
$("#captchaimglogin").attr('src','modules/captcha/captcha.php?r=login&x=34&y=75&z=119&?newtime=' + (new Date()).getTime());
}</script></div>
<div style="padding-bottom:5px"><input type="text" name="captcha" id="captcha_login" style="width:180px"></div>
<div style="padding-bottom:5px"><input type="submit" name="login" value="Login" class="orange"></div>
</form>===========================================
上面这段内容:1、把 <div style="padding-bottom:5px"><div style="padding:5px 0px"><a href="javascript:void(0);" onclick="captchareload2();"><img src="modules/captcha/captcha.php?r=login" id="captchaimglogin" border="0"></a></div>
<script>function captchareload2(){
$("#captchaimglogin").attr('src','modules/captcha/captcha.php?r=login&x=34&y=75&z=119&?newtime=' + (new Date()).getTime());
}</script></div>,取出来,用正则匹配2、匹配 在<form></form>里是否包含 第1点 的内容,有包含 输出真,没包含输出假=======================================我是在搞不懂了,请帮帮忙
<form class="formclass" id="loginform" method="post" onsubmit="return loginform();">
<div style="padding-bottom:5px">Username</div>
<div style="padding-bottom:5px"><input type="text" name="username" style="width:180px"></div>
<div style="padding-bottom:5px">Password</div>
<div style="padding-bottom:5px"><input type="password" name="password" style="width:180px"></div>
<div style="padding-bottom:5px"><div style="padding:5px 0px"><a href="javascript:void(0);" onclick="captchareload2();"><img src="modules/captcha/captcha.php?r=login" id="captchaimglogin" border="0"></a></div>
<script>function captchareload2(){
$("#captchaimglogin").attr('src','modules/captcha/captcha.php?r=login&x=34&y=75&z=119&?newtime=' + (new Date()).getTime());
}</script></div>
<div style="padding-bottom:5px"><input type="text" name="captcha" id="captcha_login" style="width:180px"></div>
<div style="padding-bottom:5px"><input type="submit" name="login" value="Login" class="orange"></div>
</form>
html;preg_match('/<div style="padding-bottom:5px"><div style="padding:5px 0px">.+(?=javascript:void\(0\)).+<\/script><\/div>/s',$s,$m);
print_r($m);第二个问题用:strpos()就行了。
<form class="formclass" id="loginform" method="post" onsubmit="return loginform();">
<div style="padding-bottom:5px">Username</div>
<div style="padding-bottom:5px"><input type="text" name="username" style="width:180px"></div>
<div style="padding-bottom:5px">Password</div>
<div style="padding-bottom:5px"><input type="password" name="password" style="width:180px"></div>
<div style="padding-bottom:5px"><div style="padding:5px 0px"><a href="javascript:void(0);" onclick="captchareload2();"><img src="modules/captcha/captcha.php?r=login" id="captchaimglogin" border="0"></a></div>
<script>function captchareload2(){
$("#captchaimglogin").attr('src','modules/captcha/captcha.php?r=login&x=34&y=75&z=119&?newtime=' + (new Date()).getTime());
}</script></div>
<div style="padding-bottom:5px"><input type="text" name="captcha" id="captcha_login" style="width:180px"></div>
<div style="padding-bottom:5px"><input type="submit" name="login" value="Login" class="orange"></div>
</form>
string;$pattern = "/<div style=\"padding-bottom:5px\"><div.+<\/script><\/div>/isU";preg_match_all($pattern, $str, $newstr);if($newstr[0][0]!=""){
echo $newstr[0][0];
}
请问: $s=<<<html
html;
这个有什么作用,我放在别的地方却不行,总是 提示:
Parse error: syntax error, unexpected $end in E:\APMServ5.2.6\www\htdocs\n\admin\E.php on line 96是因为加上 $s=<<<html
html;
后才有这个错误提示。
又比如说这种格式的:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
…………
</head>
<body>
…………
…………
<form class="formclass" id="loginform" method="post" onsubmit="return loginform();">
<table>
<tr>
<td>
这里是表格,要在整个HTML页面代码中提取<form></form>里的整个表格,当然在form外也有其他表格,但只要form里的表格
</td>
</tr>
</table>
</form>
</body>
</html>
我用正则:
$pattern = "#<form class=\"formclass\" method=\"post\" onsubmit=\"return directrefaction();\" id=\"reflist\">(.*)<\/form>#";
preg_match_all($pattern,$str,$stra);
print_r($stra);
打印出来是一个3维数组,但内容都是空的,即只有数组结构,并没有抓到实际的内容,不知道为什么
=========================
然后,我将整个html代码放到
$str = <<<string
string;里面
用同样的正则,
测试时,总是 提示:
Parse error: syntax error, unexpected $end in E:\APMServ5.2.6\www\htdocs\n\admin\E.php on line 96
----------------------
郁闷了。要怎么才能在整个html页面里提出在form里的表格?
大大 ,我晕了。
string;$s=<<<html
html;
================================
整个是啥意思?
http://www.php.net/manual/zh/language.types.string.php#language.types.string.syntax.heredoc
不过大大的方法我收藏了额,说不定哪天用得到,谢谢。做完思考与经验总结,散分结帖。