使用PHP數(shù)組實現(xiàn)無限分類,不使用數(shù)據(jù)庫,不使用遞歸.
Jun 13, 2016 pm 12:35 PM
復制代碼 代碼如下:
class?cat
{
????public?$data;
????public?function?__construct()?
????{
????????@include?"data.php";
????????$this->data?=?$class;
????}
????public?function?CreateSortLevel($fatherlevel)
????{
????????if(empty($fatherlevel))
????????{
????????????if(is_array($this->data))
????????????{
????????????????$fast_level?=?array();
????????????????foreach($this->data?as?$value)
????????????????{
????????????????????if(strlen($value["sortlevel"])?==?3)
????????????????????{
????????????????????????$fast_level[]?=?$value["sortlevel"];
????????????????????}
????????????????}
????????????????$max_fast_level?=?max($fast_level);
????????????????unset($fast_level);
????????????????$sub???=?ceil($max_fast_level)?+?1;
????????????????switch(strlen($sub))
????????????????{
????????????????????case?1:
????????????????????????return?"00{$sub}";
????????????????????????break;
????????????????????case?2:
????????????????????????return?"0{$sub}";
????????????????????????break;
????????????????????case?3:
????????????????????????return?$sub;
????????????????????????break;
????????????????}
????????????}
????????????else
????????????{
????????????????return?"001";
????????????}
????????}
????????foreach($this->data?as?$val)
????????{
????????????if(eregi("^".$fatherlevel.".{3}$",$val["sortlevel"]))
????????????{
????????????????$level[]?=?$val["sortlevel"];
????????????}
????????}
????????if(is_array($level))
????????{
????????????$max_two_level?=?max($level);
????????????$sub???=?ceil(substr($max_two_level,-3))?+?1;
????????????switch(strlen($sub))
????????????{
????????????????case?1:
????????????????????return?substr($max_two_level,0,strlen($max_two_level)-1).$sub;
????????????????????break;
????????????????case?2:
????????????????????return?substr($max_two_level,0,strlen($max_two_level)-2).$sub;
????????????????????break;
????????????????case?3:
????????????????????return?substr($max_two_level,0,strlen($max_two_level)-3).$sub;
????????????????????break;
????????????}
????????}
????????else
????????{
????????????return?$fatherlevel."001";
????????}
????}
????public?function?orders()
????{
????????$op?=?$this->data;
????????$this->array_usort($op,"sortlevel",SORT_ASC);
????????return?$op;
????}
????public?function?add_cat($sortname,$sortlevel)
????{
????????$data?=?time();
????????$arr?=?array
????????(
????????????"{$data}"?=>?array
????????????(
??????????????"sortname"??=>?$sortname,
??????????????"sortlevel"?=>?$this->CreateSortLevel($sortlevel)
????????????)
?????????);
????????$rs?=?$this->data?+?$arr;
????????$this->add_wirte($rs);
????}
????private?function?array_usort(&$array)
????{
????????$args?=?func_get_args();
????????for($i=1,$cmd='',$size=count($args);$i????????{
????????????$num???=?$i;
????????????$order?=?"";
????????????$con???=?"@strcmp($a['$args[$num]'],$b['$args[$num]'])";
????????????while(++$i?????????????{
????????????????if($args[$i]?===?SORT_NUMERIC)
????????????????{
????????????????????$con?=?"($a['$args[$num]']-$b['$args[$num]'])";
????????????????}
????????????????else?if($args[$i]?===?SORT_DESC)
????????????????{
????????????????????$order?=?"-1*";
????????????????}
????????????????else?if(is_string($args[$i]))
????????????????{
????????????????????$i--;
????????????????????break;
????????????????}
????????????}
????????????$cmd?.=?"if($num?=?$con)return?$order$num;else?";
????????????if($order?!=?'')
????????????{
????????????????$i++;
????????????}
????????}
????????@usort($array,@create_function('$a,$b',"$cmd?return?0;"));
????}
????public?function?wirte($sortname,$sortlevel)
????{
????????$array??=?"????????$array?.=?'$class?=?array'."rn(rn";
????????$array?.=?'??"'.time().'"?=>?array'."rn";
????????$array?.=?'??????('."rn";
????????$array?.=?'???????????"sortname"?=>?"'.$sortname.'"'.",rn";
????????$array?.=?'???????????"sortlevel"?=>?"'.$this->CreateSortLevel($sortlevel).'"'."rn";
????????$array?.=?'??????)'."rn";
????????$array?.=?")rn?>";
????????file_put_contents("data.php",$array);
????}
????public?function?add_wirte($rs)
????{
????????$array??=?"????????$array?.=?'$class?=?array'."rn(rn";
????????foreach($rs?as?$key=>$value)
????????{
????????????$array?.=?"rn";
????????????$array?.=?'??"'.$key.'"?=>?array'."rn";
????????????$array?.=?'??????('."rn";
????????????$array?.=?'???????????"sortname"?=>?"'.$value["sortname"].'"'.",rn";
????????????$array?.=?'???????????"sortlevel"?=>?"'.$value["sortlevel"].'"'."rn";
????????????$array?.=?'??????),';
????????}
????????$array??=?substr($array,0,-1);
????????$array?.=?"rn)rn?>";
????????file_put_contents("data.php",$array);
????}
}
$cat?=?new?cat();
if($_GET["action"]?==?"add")
{
????if(strlen($_POST["sortname"])?????{
????????echo?'<script>alert("請?zhí)砑臃诸惷?quot;)</script>';
????????echo?'<script>location.href="/cat.php?action=tpl"</script>';
????????exit;
????}
????if(file_exists("data.php"))
????{
????????$cat->add_cat($_POST["sortname"],$_POST["sortlevel"]);
????????echo?'<script>alert("添加成功")</script>';
????????echo?'<script>location.href="/cat.php"</script>';
????????exit;
????}
????else
????{
????????$cat->wirte($_POST["sortname"],$_POST["sortlevel"]);
????????echo?'<script>alert("添加成功")</script>';
????????echo?'<script>location.href="/cat.php"</script>';
????????exit;
????????exit;
????}
}
if($_GET["action"]?==?"tpl")
{
????echo?'
????exit;
}
foreach($cat->orders()?as?$value)
{
????$level?=?strlen(substr($value['sortlevel'],0,-3));
????for($i?=?0;?$i?????{
????????echo?"-";
????}
????echo?$value["sortname"];
????echo?"
";
}
?>

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











PHP?? ?? ?? ID? ?? ??? Session_id () ??? ???? ???? Session_Start ()? ???? ????? ??????. 1. ??? ????? ?? _start ()? ?????. 2. Session_id ()? ???? ?? ID? ?? ABC123DEF456GHI789? ??? ???? ?????. 3. ??? ?? ??? Session_Start ()? ??????, ???? ???? ?????? ?? ??? ?????? ??? ??????. 4. ?? ID? ??, ?? ?? ? ?? ?? ??? ??? ? ??? ?????? ???????. ??? ???? ????? ID? ????? ?? ? ??? ??????.

PHP ????? ?? ???? ????? Syntax substr (String $ String, int $ start,? int $ length = null) ? substr () ??? ??? ? ??? ??? ???? ??? ??? ?????. ???? ?? ?? ??? ??? ?? ? ?? MB_SUBSTR () ??? ???? ?? ??? ??????. ?? ???? ?? ???? ?? ????? ?? exploit () ?? strtr ()? ???? ?? ?? ??? ?? ??? ?? ??? ?? ??? ? ????.

UnitTestingInphPinvolvesVeverifying individualCodeUnitsInitsIntsormeStodStocatchBugSearlyLylyLearLiAberFactoring.1) setupphPunitviacomposer, createEatestDirectory, and ConfigeAuteAutoloadandPhpunit.xml.2) writeTestCases-oct-oct-asserterfat

PHP?? ?? ???? ??? exploit () ??? ???? ???? ??? ???? ????. ? ??? ??? ?? ??? ?? ???? ?? ???? ??? ??? ?????. ??? Exploit (???, ???, ??)??, ??? ???? ????? ???? ?? ?????, ??? ????? ?? ?? ?????? ??? ?? ?????. ?? ?? $ str = "Apple, Banana, Orange"; $ arr = Explode ( ",", $ str); ??? [ "Apple", "Bana???

JavaScript?? ??? ?? ?? ???? ??? ??????. ?? ???? ??? ?? ?? ???? ()? ??? array.includes (valuetofind)???. ?? ??? ?? ???? ?? ??. indexof (20)! == -1? ?? indexof ()? ??????. ?? ?? ??? ???? ?? user.some (user => user.id === 1)? ?? ?? ??? ?? () ???? ???????.

JavaScript ??? ??? ?? ?? ? ?? ???? ????. ?? ???? ???, ??, ??, ?, ???? ?? ? ??? ?????. ?? ????? ?? ?? ? ? ??? ????? ?? ??? ??? ????. ??, ?? ? ??? ?? ?? ??? ??? ??? ???? ??? ??? ???? ??? ?? ??? ????. ?? ? ????? ??? ???? ? ??? ? ??? TypeofNull? ??? ?????? ??? ? ????. ? ? ?? ??? ???? ?????? ????? ???? ??? ???? ? ??? ? ? ????.

STD :: Chrono? ?? ?? ??, ?? ?? ??, ?? ?? ? ?? ?? ? ?? ?? ??? ???? C?? ???? ??? ?????. 1. std :: chrono :: system_clock :: now ()? ???? ?? ??? ?? ? ??? ?? ??? ???? ?? ? ? ??? ??? ??? ???? ?? ?? ? ????. 2. std :: Chrono :: steady_clock? ???? ?? ??? ???? ?? ??? ???? duration_cast? ?? ?? ?, ? ? ?? ??? ??????. 3. ?? (time_point) ? ?? (??)? ?? ??? ? ? ??? ?? ??? ? ?? epoch (epoch)???? ???????.

toaccessenvironmentvariablesinphp, usegetenv () ?? $ _envsuperglobal.1.getenv ( 'var_name') retrievespescificvariable.2. $ _ en v [ 'var_name'] accessesvariablesifvariables_orderinphp.iniincludes "e".setvariablesviacliwithvar = valuephpscript.php, inapach
