[Mr. Mai] What is the difference between Laravel framework and ThinkPHP? (1) laravelthinkphp

Source: Internet
Author: User

[Mr. Mai] What is the difference between Laravel framework and ThinkPHP? (1) laravelthinkphp

As a beginner in PHP Laravel framework, I found the difference between it and the TP framework during the learning process. Due to time issues and lack of knowledge, I should first write out some of them, there is something wrong with it. I hope you guys can make it right...

1. Different rendering templates: In the Laravel framework, return view () is used to render templates. In ThinkPHP, $ this-> display () is used to render templates;

2. in actual development, we often encounter this problem, that is, the development location is not fixed, which causes us to frequently change the database configuration, causing trouble for the development work, TP still does not avoid this "disaster"; in laravel framework ,. the emergence of the env Environment File solves this problem. We only need to configure it in different work locations. configure the env file because it is git or svn ". env will not be submitted to the server along with the file ";

3. Laravel framework provides a large number of closures. As a cainiao, I currently only use the use method, that is, how can I use outer variables inside a function?

    

    

4. note differences in post values: In the Laravel framework, cross-site attacks are taken into account. Therefore, if the form is used to transmit values in post mode, if {csrf_filed ()} is not added to the form, the TokenMethodnotfound syntax error is reported. The TP framework needs to manually complete the code to prevent cross-site attacks;

    

5. differences in the Writing Method of conditional judgment statements: In the Laravel framework, if else judgment statements and foreach statements must start with @ if and end with @ endif. if not, a syntax error is reported, @ foreach @ endforeach: Similarly, the TP framework is consistent with the usage of PHP syntax rules. The ifesle statement is used to judge and foreach loop traversal.

    

6. laravel has a large number of built-in methods for developers to use. It is closer to the development idea of "Let objects do everything" in actual applications. For example, during form verification in the background, laravel has a large number of built-in verification methods, such as user name verification: We can use 'username' => 'required' (cannot be blank) in the validate method) | alpha_dash (which must contain numbers, letters, and underscores) | between: 6, 18 (between the digits); also has built-in e. g. emial; same: field name; diff: A large number of methods such as field names greatly improve the development speed;

Code to be improved is only used in experiments

7. Encryption Method

In the TP framework, the user name and password are encrypted using the md5 (); method. However, the md5 method can be used for reverse cracking, in addition, strings encrypted by md5 with the same password under the same rules may be the same, which reduces the security of md5 encryption; however, the Laravel framework has a built-in "Hash" Hash encryption one-way encryption method, and the strings encrypted with the same parameters will never be the same, which improves security.

  

    

    

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.