


PHP entry-level tutorial: teach you to quickly learn PHP language_PHP tutorial
Bkjia.Com Programming Documentation This article will introduce some PHP entry-level tutorials: Learn PHP quickly.
PHP syntax.
1. Embedding method:
Similar to ASP's <%, PHP can be . Of course, you can also specify it yourself.
2. Cited documents:
There are two ways to reference files: require and include.
Require is used as require(”MyRequireFile.php”);. This function is usually placed at the front of the PHP program. Before the PHP program is executed, it will first read in the file specified by require and make it a part of the PHP program web page. Commonly used functions can also be introduced into web pages in this way.
include is used like include(”MyIncludeFile.php”);. This function is generally placed in the processing part of flow control. The PHP program web page only reads the include file when it reads it. In this way, the process of program execution can be simplified.
3. Annotation method:
The following is the quoted content:
/* This example uses a multi-line comment */echo "This is the second example. n";
|
4. Variable type:
The following is the quoted content: $mystring = "I am a string " ; $NewLine = "Newline n" ; $int1 = 38 ; $float1 = 1.732 ; $float2 = 1.4E 2 ; $MyArray1 = array( " " , " Chou " , " Yin " , " Mao " ); |
Two problems arise here. First, PHP variables start with $, and second, PHP statements end with ;. ASP programmers may not adapt to this. These two omissions are where most errors in the program lie.
5. Operation symbols:
Mathematical operations: Symbol Meaning
以下为引用的内容: $a = “PHP 4″ ; |
– Subtraction * Multiplication
/ Division
% Remainder Accumulation
– Decrement
String operations:
There is only one operator symbol, which is the English period. It can concatenate strings into new merged strings. Similar to &
in ASP
The following is the quoted content: $a = “PHP 4″; $b = “Powerful”; echo $a.$b; ?> |
Logical operations:
Symbol meaning
< Less than
> Greater than<= Less than or equal to
if (expr) { statement } |
Where expr is the condition for judgment, usually logical operation symbols are used as the condition for judgment. The statement is the execution part of the program that meets the conditions. If the program has only one line, the curly brackets {} can be omitted.
Example: This example omits the curly braces.
以下为烈火建站学院引用的内容: if ($state==1)echo “哈哈” ; ?> Special attention here is that the judgment of equality is == instead of =. ASP programmers may often make this mistake, = is assignment. Example: The execution part of this example has three lines, and the curly brackets cannot be omitted.
The second type is to add an else condition in addition to if, which can be interpreted as "how to deal with something if something happens, otherwise how to solve it." The syntax is as follows if (expr) { statement1 } else { statement2 } Example: Modify the above example into a more complete process. Since there is only one line of instructions for executing else, there is no need to add braces.
The third type is the recursive if..else loop, which is usually used in various decision-making judgments. It combines several if..else statements for processing. Look directly at the example below
The above example only uses a two-level if..else loop to compare the two variables a and b. When actually using this kind of recursive if..else loop, please use it with caution, because too many levels of loops can easily cause problems with the design logic, or missing braces, etc., can cause inexplicable problems in the program. 2. There is only one type of for loop with no changes. Its syntax is as follows for (expr1; expr2; expr3) { statement } where expr1 is the initial value of the condition. expr2 is the condition for judgment, and logical operators are usually used as the condition for judgment. expr3 is the part to be executed after statement is executed. It is used to change the conditions for the next loop judgment, such as adding one, etc. The statement is the execution part of the program that meets the conditions. If the program has only one line, the curly brackets {} can be omitted. The following example is written using a for loop.
3. The switch loop usually handles compound conditional judgments. Each sub-condition is part of the case instruction. In practice, if many similar if instructions are used, it can be synthesized into a switch loop. The syntax is as follows switch (expr) { case expr1: statement1; break; case expr2: statement2; break; default: statementN; break; } The expr condition is usually a variable name. The exprN after case usually represents the variable value. After the colon is the part to be executed that meets the condition. Be sure to use break to break out of the loop.
What needs to be noted here is break; don’t omit it, default, it’s okay to omit it. Obviously, using the if loop in the above example is very troublesome. Of course, when designing, you should put the conditions with the greatest probability of occurrence at the front and the conditions with the least occurrence at the end, which can increase the execution efficiency of the program. In the above example, since the probability of occurrence is the same every day, there is no need to pay attention to the order of the conditions. Build database In ASP, if it is an ACCESS database, you can directly open ACCESS to edit the MDB file. If it is a SQL SERVER, you can open the Enterprise Manager to edit the SQL SERVER database. However, in PHP, the command line editing of MY SQL may It's very troublesome for beginners. It doesn't matter. You can download PHPMYADMIN and install it. You can rely on it to build and edit the database in the future. Let’s talk about its use below. Then select the created database in the drop-down menu on the left. belowCreate a new table in the database shop: Fill in the table name and the approximate number of fields you think (it doesn’t matter if there are not enough or too many, you can add them later or default them), and press Execute.
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
![]() Hot AI Tools![]() Undresser.AI UndressAI-powered app for creating realistic nude photos ![]() AI Clothes RemoverOnline AI tool for removing clothes from photos. ![]() Undress AI ToolUndress images for free ![]() Clothoff.ioAI clothes remover ![]() Video Face SwapSwap faces in any video effortlessly with our completely free AI face swap tool! ![]() Hot Article
Roblox: Grow A Garden - Complete Mutation Guide
3 weeks ago
By DDD
Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How to fix KB5055612 fails to install in Windows 10?
3 weeks ago
By DDD
Nordhold: Fusion System, Explained
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
![]() Hot Tools![]() Notepad++7.3.1Easy-to-use and free code editor ![]() SublimeText3 Chinese versionChinese version, very easy to use ![]() Zend Studio 13.0.1Powerful PHP integrated development environment ![]() Dreamweaver CS6Visual web development tools ![]() SublimeText3 Mac versionGod-level code editing software (SublimeText3) ![]() Hot Topics
Java Tutorial
![]() ![]()
CakePHP Tutorial
![]() ![]()
Laravel Tutorial
![]() ![]()
PHP Tutorial
![]() ![]()
C# Tutorial
![]() ![]() ![]() PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners. ![]() PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7 ![]() PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved. ![]() PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries. ![]() PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers. ![]() PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning. ![]() PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development. ![]() PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning. ![]() |