在Mac上写的PHP代码,可正常执行,但是在Web Server上运行时会匹配不到。
Mac上PHP Version 5.5.30,CentOS 7服务器上的是PHP Version 5.6.15。
就是在执行到第二个if时会保未找到该用户!
//正则匹配页面中的用户信息,如果匹配成功则进入编辑页面
if ($c = preg_match_all ('/(\/UserManage\/edit\/id\/\d*)/is', $search_result, $matches))
{
$string1 = $matches[1][0];
//获取页面中的用户信息,并进入编辑页面
$match_user = curl_init();
curl_setopt($match_user, CURLOPT_URL, 'https://crm.pzoom.com'.$string1);//登陆后要从哪个页面获取信息
curl_setopt($match_user, CURLOPT_POST, 1);
curl_setopt($match_user, CURLOPT_COOKIEFILE, PZOOM_COOKIE_FILE);// 获取COOKIE文件
curl_setopt($match_user, CURLOPT_RETURNTRANSFER, 1);//设定返回 的数据是否自动显示
curl_setopt($match_user, CURLOPT_HEADER, false);//设定是否显示头信 息
curl_setopt($match_user, CURLOPT_NOBODY, false);//设定是否输出页面 内容
$edit_info = curl_exec($match_user);//返回结果
curl_close($match_user); //关闭
if ($c2=preg_match_all ('/(.*?value=\"(.*)\")/is', $edit_info, $edit_info_match))
{
if ($c3=preg_match_all ('/(.*?value=\"(.*)\") (checked)/is', $edit_info, $match_radio))
{
}else{
echo "匹配失败!";
}
if ($c4=preg_match_all ('/(textarea class="descript_cont" name="user\\[userDesc\\]" id="userDesc">)(.*)()/is', $edit_info, $match_textarea))
{
}else{
echo "匹配失败!";
}
$call_id = $edit_info_match[2][0];
$user_userid = $edit_info_match[2][1];
$user_name = $edit_info_match[2][2];
$user_sex = $match_radiop[1][0];
$user_tel = $edit_info_match[2][5];
$user_mobile = $edit_info_match[2][6];
$user_mail = $edit_info_match[2][7];
$user_departmentid = $edit_info_match[2][9];
$user_address = $edit_info_match[2][10];
$call_areacode = $edit_info_match[2][12];
$call_pwd = $edit_info_match[2][14];
$user_desc = $match_textarea[2][0];
$user_id = substr($string1,-4);
//发起新的请求,并提交用户输入的分机号
$edit_userinfor = curl_init();
curl_setopt($edit_userinfor, CURLOPT_URL, 'https://crm.pzoom.com/UserManage/edit');//登陆后要从哪个页面获取信息
curl_setopt($edit_userinfor, CURLOPT_POST, 1);
$submit_userinfo = "call[id2]=$call_id&user[userid]=$user_userid&user[username]=$user_name&user[sex]=$user_sex&user[usertel]=$user_tel&user[usermobile]=$user_mobile&user[useremail]=$user_mail&user[departmentid]=$user_departmentid&user[address]=$user_address&call[cno]=$tel_number&call[areaCode]=021&isManager=1&call[pwd]=Aa123456&user[userDesc]=$user_desc&user[num]=1&user[id]=$user_id";
curl_setopt($edit_userinfor, CURLOPT_POSTFIELDS, $submit_userinfo);//传递数据
curl_setopt($edit_userinfor, CURLOPT_COOKIEFILE, PZOOM_COOKIE_FILE);// 获取COOKIE文件
curl_setopt($edit_userinfor, CURLOPT_RETURNTRANSFER, 1);//设定返回 的数据是否自动显示
curl_setopt($edit_userinfor, CURLOPT_HEADER, false);//设定是否显示头信 息
$submint_userinfo = curl_exec($edit_userinfor);//返回结果
curl_close($edit_userinfor); //关闭
}else{
die("未找到该用户!");
}
}else{
die("未找到该用户!");
}
}
难道PHP版本不同,正则表达式也不一样?