Home > Backend Development > PHP Tutorial > zencart中的一个函数不知道是要做什么的?

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

WBOY
Release: 2016-06-06 20:37:52
Original
997 people have browsed it

<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>
Copy after login
Copy after login

这是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>
Copy after login
Copy after login

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

Related labels:
php
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