在再简化代码需求~该如何解决

WBOY
Release: 2016-06-13 11:45:49
Original
930 people have browsed it

在再简化代码需求~~

$x = md5($row['userid']."+".$row['pwd']);<br />$str = base64_encode($row['userid'].".".$x);<br />//print_r($str);die;<br />$b=explode("/",DEDEROOT);<br />$c=$b['1'];<br />$a ='/reg/resetpw.php?p='.$str;<br />$a = "<a href='$a'>$c.$a</a>"; 
Copy after login

这代码还能简化吗?变量有点多了 。
------解决方案--------------------
如果你的php版本在5.4及5.4以上的话,你的这段代码
$b=explode("/",DEDEROOT);
$c=$b['1'];
可以简化为
$c=explode("/",DEDEROOT)[1];
------解决方案--------------------
<br />list($b,$c,$d)=explode("/",DEDEROOT);<br />$a ='/reg/resetpw.php?p='.base64_encode($row['userid'].".".md5($row['userid']."+".$row['pwd']));<br />$a = "<a href='$a'>$c.$a</a>";<br />
Copy after login

------解决方案--------------------
不要太过于简化,因为那会导致PHP 版本兼容性問題
------解决方案--------------------
strtok(DEDEROOT, "/");<br />$a ='/reg/resetpw.php?p=' . base64_encode($row['userid'].".".md5($row['userid']."+".$row['pwd']));<br />$a = "<a href='$a'>".strtok("/")."$a</a>";
Copy after login
 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!