发布于 2014-09-10 12:53:01 | 139 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的PHP面向对象编程,程序狗速度看过来!

PHP开源脚本语言

PHP(外文名: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言。语法吸收了C语言、Java和Perl的特点,入门门槛较低,易于学习,使用广泛,主要适用于Web开发领域。PHP的文件后缀名为php。


本文是一个用php实现的可以用来生成sessionid和生成随机密码的方法,感兴趣的同学参考下.
<?
        //----------------------------------------------------
        // Function GetSID()
        //
        // Parameters : $nSize number of caracters, default 24
        // Return value : 24 caracters string
        //
        // Description : This function returns a random string
        // of 24 caracters that can be used to identify users
        // on your web site in a more secure way. You can also  
        // use this function to generate passwords.
        //----------------------------------------------------
        function GetSID ($nSize=24) {

            // Randomize
            mt_srand ((double) microtime() * 1000000);
            for ($i=1; $i<=$nSize; $i++) {

                // if you wish to add numbers in your string,  
                // uncomment the two lines that are commented
                // in the if statement
                $nRandom = mt_rand(1,30);
                if ($nRandom <= 10) {
                    // Uppercase letters
                    $sessionID .= chr(mt_rand(65,90));
            //    } elseif ($nRandom <= 20) {
            //        $sessionID .= mt_rand(0,9);
                } else {
                    // Lowercase letters
                    $sessionID .= chr(mt_rand(97,122));
                }

            }         
            return $sessionID;
        }
        // Test the function  
        echo GetSID(16);
    ?> 



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务