首页 >后端开发 >php教程 >zencart中的一个函数不知道是要做什么的?

zencart中的一个函数不知道是要做什么的?

WBOY
WBOY原创
2016-06-06 20:37:52994浏览

<code>function GBcase($text, $case)
{
    $case = strtolower($case);
    if ($case != "upper" && $case != "lower" && $case != "ucwords" && $case != "ucfirst")
    {
        return "函数用法错误。 $case";
    }
    else
    {
        $ucfirst = 0;
        $ucwords = 0;
        $news    = "";
        $l       = strlen($text);
        $GB      = 0;
        $english = 0;

        $a = 0;
        while ($a = HexDec("0x81"))
            {

                $GB      = 1;
                $english = 0;
                $news .= $ch;
                $ucwords = 0;

            }
            elseif ($GB == 1 && ord($ch) >= HexDec("0x40") && $english == 0)
            {
                $news .= "$ch";
                $ucwords = 0;
                $GB      = 0;

            }
            else
            {
                if ($case == "upper")
                {
                    $news .= strtoupper($ch);
                }
                elseif ($case == "lower")
                {
                    $news .= strtolower($ch);
                }
                elseif ($case == "ucwords")
                {
                    if ($ucwords == 0)
                    {
                        $news .= strtoupper($ch);
                    }
                    else
                    {
                        $news .= strtolower($ch);
                    }
                    $ucwords = 1;
                }
                elseif ($case == "ucfirst")
                {
                    if ($ucfirst == 0)
                    {
                        $news .= strtoupper($ch);
                        $ucfirst = 1;
                    }
                    else
                    {
                        $news .= strtolower($ch);
                        $ucfirst = 1;
                    }
                }
                else
                {
                    $news .= $ch;
                }
                if ($ch == " " || $ch == "\n")
                {
                    $ucwords = 0;
                }
                $english = 1;
                $GB      = 0;

            }

            $a++;

        } // END OF while
        return $news;
    } // end else
}
</code>

这是zencart中文版中,中文版补充的一个函数,一个用例就是对$sql查询语句进行转换,如GBcase($sql,'lower'),这里要对$sql要做的就是根据$page/$size/$sql/$rows进行分页,如果要进行大小写转换直接用函数不就行了,我对ASCII编码这些也不是很懂,所以看不太懂这个。

回复内容:

<code>function GBcase($text, $case)
{
    $case = strtolower($case);
    if ($case != "upper" && $case != "lower" && $case != "ucwords" && $case != "ucfirst")
    {
        return "函数用法错误。 $case";
    }
    else
    {
        $ucfirst = 0;
        $ucwords = 0;
        $news    = "";
        $l       = strlen($text);
        $GB      = 0;
        $english = 0;

        $a = 0;
        while ($a = HexDec("0x81"))
            {

                $GB      = 1;
                $english = 0;
                $news .= $ch;
                $ucwords = 0;

            }
            elseif ($GB == 1 && ord($ch) >= HexDec("0x40") && $english == 0)
            {
                $news .= "$ch";
                $ucwords = 0;
                $GB      = 0;

            }
            else
            {
                if ($case == "upper")
                {
                    $news .= strtoupper($ch);
                }
                elseif ($case == "lower")
                {
                    $news .= strtolower($ch);
                }
                elseif ($case == "ucwords")
                {
                    if ($ucwords == 0)
                    {
                        $news .= strtoupper($ch);
                    }
                    else
                    {
                        $news .= strtolower($ch);
                    }
                    $ucwords = 1;
                }
                elseif ($case == "ucfirst")
                {
                    if ($ucfirst == 0)
                    {
                        $news .= strtoupper($ch);
                        $ucfirst = 1;
                    }
                    else
                    {
                        $news .= strtolower($ch);
                        $ucfirst = 1;
                    }
                }
                else
                {
                    $news .= $ch;
                }
                if ($ch == " " || $ch == "\n")
                {
                    $ucwords = 0;
                }
                $english = 1;
                $GB      = 0;

            }

            $a++;

        } // END OF while
        return $news;
    } // end else
}
</code>

这是zencart中文版中,中文版补充的一个函数,一个用例就是对$sql查询语句进行转换,如GBcase($sql,'lower'),这里要对$sql要做的就是根据$page/$size/$sql/$rows进行分页,如果要进行大小写转换直接用函数不就行了,我对ASCII编码这些也不是很懂,所以看不太懂这个。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn