In our previous articles, we have always introduced to you how to intercept strings and convert strings. So today's course will introduce to you the development of PHP safe strings. Before that, When writing the cookie value, I looked at the cookie files of Google and Baidu. The value inside is a long string of characters. So I will introduce to you how to generate a safe string.
1. Before we start, we need to download the PHP secure string library we need for this section: http://www.php.cn/xiazai/leiku/607
2. After the download is complete, know the php class library file, unzip it to the local directory, and create a new php file!
3. Call the class in the new php file and instantiate it:
<?php include_once "stringanquan.php"; //引入类库 $obj= new genRandomString(); //实例化类 $obj->len='30'; //len 为自定义的字符长度 echo $obj->provideRandString(); //输出安全字符串
Finally run the file, the running result is as shown below:
The above is the detailed content of PHP safe string development ideas and code sharing. For more information, please follow other related articles on the PHP Chinese website!