Rumah  >  Artikel  >  pembangunan bahagian belakang  >  php5.2和php5.3转换问题详解

php5.2和php5.3转换问题详解

小云云
小云云asal
2018-01-18 09:17:251538semak imbas

本文主要和大家分享php5.2和php5.3转换问题详解,我们会通过代码进行讲解,希望能帮助到大家。

a.php php5.2代码截取

elseif($act=="resumes")
{
locoyspider_addresumes();
exit("添加失败");
}
elseif($act=="jobs")
{
$companyname=isset($_POST['companyname'])?trim($_POST['companyname']):exit('公司名称不能为空!');
$companyinfo=get_companyinfo($companyname);
if ($companyinfo)
{
locoyspider_addjobs($companyinfo);
}
else
{
if (locoyspider_addcompany($companyname))
{
$companyinfo=get_companyinfo($companyname);
locoyspider_addjobs($companyinfo);
}
else
{
exit("添加失败");
}
} 
}


b.php php5.2代码截取

function locoyspider_addresumes()
{
global $locoyspider,$db;
        $setsqlarr['uid']=locoyspider_user_register(trim($_POST['email']),2);
}
function locoyspider_user_register($email=NULL,$utype=1)
{
global $db,$locoyspider;
$setsqlarr['username']=$locoyspider['reg_usname'].uniqid().time();
$setsqlarr['pwd_hash']=res_randstr();
//reg_password
if ($locoyspider['reg_password_tpye']=="1")
{
$pwd=$setsqlarr['username'];
}
elseif ($locoyspider['reg_password_tpye']=="3")
{
$pwd=$locoyspider['reg_password'];
}
else
{
$pwd=res_randstr(7);
}
//email
if (empty($email) || !preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/",$email))
{
$email=time().uniqid().$locoyspider['reg_email'];
}
else
{
$email=$email;
}
$setsqlarr['password']=md5(md5($pwd).$setsqlarr['pwd_hash']);
$setsqlarr['email']=$email;
$setsqlarr['utype']=$utype;
$setsqlarr['reg_time']=time();
$setsqlarr['robot']=1;
$reg_id=inserttable(table('members'),$setsqlarr,true);
if (!$reg_id) return false;
if(!$db->query("INSERT INTO ".table('members_points')." (uid) VALUES ('{$reg_id}')"))  return false;
if(!$db->query("INSERT INTO ".table('members_setmeal')." (uid) VALUES ('{$reg_id}')"))  return false;
return $reg_id;
}


a.php 5.3php代码截取

elseif($act=="resume")
{
$locoyspider->locoyspider_addresumes();
exit("添加失败");
}
elseif($act=="jobs"){
$companyname=isset($_POST['companyname'])?trim($_POST['companyname']):exit('公司名称不能为空!');
$companyinfo=$locoyspider->getCompanyInfo($companyname);
if ($companyinfo){
$locoyspider->addJobs($companyinfo);
}else{
if($locoyspider->addCompany($companyname)){
$companyinfo=$locoyspider->getCompanyinfo($companyname);
$locoyspider->addJobs($companyinfo);
}else{
exit($msg);
}
}
}

b.php 5.3php代码截取

public function locoyspider_addresumes()
{
$locoyspider=$this->find_data();
$setsqlarr['uid']=userRegister(trim($_POST['email']),2);
}
private function userRegister($email=NULL,$utype='1'){
$locoyspider=$this->find_data();
$members=D("Members");
$setsqlarr['username']=$locoyspider['reg_usname'].uniqid().time();
$setsqlarr['pwd_hash']=$this->resRandStr();
//密码=用户名
if ($locoyspider['reg_password_tpye']=="1"){
$pwd=$setsqlarr['username'];
}elseif ($locoyspider['reg_password_tpye']=="3"){
$pwd=$locoyspider['reg_password'];//密码=固定设置值
}else{
$pwd=$this->resRandStr(7);//长度为7的随机字符串
}
//email
if (empty($email) || !preg_match("/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/",$email)){
$email=time().uniqid().$locoyspider['reg_email'];
}
$setsqlarr['password']=$members->make_md5_pwd($pwd,$setsqlarr['pwd_hash']);
$setsqlarr['email']=$email;
$setsqlarr['utype']=$utype;
$setsqlarr['reg_time']=time();
$setsqlarr['robot']=1;//标记为采集
$reg_id=M("Members")->add($setsqlarr);
if (!$reg_id) return false;
$setsqlarr['uid']=$reg_id;
$members->user_register($setsqlarr);
return $reg_id;
}

相关推荐:

PHP关于代码转换问题比较完善的解决办法_PHP教程

php5.3降到php5.2

php5.2.0内存管理改进_PHP教程

Atas ialah kandungan terperinci php5.2和php5.3转换问题详解. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:Mac切换php版本方法Artikel seterusnya:PHP使用Redis实例详解