Basic Questions for Beginners in PHP
My younger brother to learn PHP, has always been to do ASP. PHP has a general understanding of the syntax, but also downloaded someone else's code template reference, I would like to ask you two questions
1. In 1, PHP code is mixed with HTML to write, can I ask you to write separately? HTML to HTML code, PHP code to PHP code so, two kinds of code to write together feel very messy and not conducive to maintenance AH
2.2 shows that there are two PHP code in the body, so when the page is loaded, it runs that piece of code? Or are they running in two sections? Which section to run first? If there are two buttons on the same page to implement different functions, then how to implement Click Button 1 to execute a piece of PHP code (for example, method a)? Click button 2 to execute a PHP code (for example, Method B)?
I hope you will help the experts to answer the next
Figure 1:
Figure 2:
------Solution--------------------
1. Can I separate the code from ASP. I just know that C # implements code separation with accompanying files
PHP needs to introduce a template engine class to implement code separation
2, you do not have the basis of programming, is not the code to be separated by conditional statements do not see it?
Now that the code is in the conditional branch, it's natural to have conditional execution.
------Solution--------------------
Using a framework such as thinkphp, or a template such as: Smarty can be implemented in PHP and HTML separation
PHP files are executed from the top down order.
------Solution--------------------
Search php MVC
View is separated from logic and data!
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