Beginners to ask a simple logic about the problem, ask for answers

Source: Internet
Author: User
Rookie ask a simple logic question, seek answers
I want to achieve 62 of the functionality of the system, but the following code can only echo out, can not return, do not know what is the reason, seek expert answers


function DWZ ($id, $str = "") {
$a =array ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", " P "," Q "," R "," s "," T "," U "," V "," w "," X "," Y "," Z "," A "," B "," C "," D "," E "," F "," G "," H "," I "," J "," K "," L "," M "," N "," O "," P "," Q " , "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
$zs = (int) ($id/sizeof ($a));
$xs = $id%sizeof ($a);
if ($zs >=sizeof ($a)) {
$STR = $a [$xs]. $str;
DWZ ($zs, $STR);
}
else{
if ($str = = "") {
return $a [$zs]. $a [$XS];
}
else{
echo $a [$zs]. $str;//This can only be output
return $a [$zs]. $str;//Return no value, do not know why
}
}
}
for ($i =999990; $i <=1000000; $i + +) {
echo DWZ ($i);
echo "
";
}
Logic Rookie simple.

Share to:


------Solution--------------------
Line 7th DWZ ($zs, $STR);
did not undertake to return
$str = DWZ ($zs, $STR);

Return $STR is also required at the end of the function;

------Solution--------------------

if ($zs >=sizeof ($a)) {
$STR = $a [$xs]. $str;
DWZ ($zs, $STR); Join Return:return DWZ here ($zs, $STR);
}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.