Method: 1. Use the assign() function to pass the string to the html page. The syntax is "$this->assign("str", string)"; 2. Use "$this-> ;display()" to call the template; 3. Use the md5 function to encrypt and output, the syntax is "{$str|md5}".
The operating environment of this article: Windows 10 system, ThinkPHP5 version, Dell G3 computer.
In the Thinkphp template, you can use the php encryption function to encrypt the string.
Create a Show controller to explain how to encrypt strings in Thinkphp templates.
In the Show controller, create an index method to pass data to the template.
In the index method, use assign to pass the string cccbbbddd to the index.html page.
In the index method, the page is rendered and outputted through the display method.
In the index.html page, the string is encrypted through the md5 function and output on the page.
Execute the index method of the Show controller in the browser and view the results.
Summary:
1. Create a Show controller, and create an index method in the Show controller.
2. In the index method, use assign to pass the string cccbbbddd to the index.html page.
3. In the index method, the page output result is rendered through the display method.
4. In the index.html page, encrypt the string through the md5 function and output it on the page.
5. Execute the index method of the Show controller in the browser and view the results.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What is the thinkphp string encryption method?. For more information, please follow other related articles on the PHP Chinese website!