I used to write to learn ASP in ten days, learn ASP.NET in ten days, etc. Now I think about writing PHP, which is more comprehensive. I won’t go into details about PHP debugging methods here. Many articles outside have introduced them, and there are many different combinations. For the time being, I am using Apache web server and MY SQL as the WEB server and database, and I am doing the program in the environment of php-4.3.3. Of course, PHPMYADMIN is indispensable for simple construction and access to view the database.
As for form design, I don’t want to say more here. It has already been introduced in "Learning ASP in Ten Days".
The following is a brief introduction to the syntax of PHP.
1. Embedding method:
Similar to ASP's . Of course, you can also specify it yourself.
2. Reference files:
There are two ways to reference files: require and include.
Require is used like 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 webpage only reads the include file when it reads it. In this way, the process of program execution can be simplified.
3. Annotation method:
<?php echo "这是第一种例子。\n" ; // 本例是 C++ 语法的注释 /* 本例采用多行的 注释方式 */ echo "这是第二种例子。\n" ; echo "这是第三种例子。\n" ; # 本例使用 UNIX Shell 语法注释 ?>
4. Variable type:
$mystring = "我是字符串" ; $NewLine = "换行了\n" ; $int1 = 38 ; $float1 = 1.732 ; $float2 = 1.4E+2 ; $MyArray1 = array( "子" , "丑" , "寅" , "卯" );
Two questions arise here. First, PHP variables start with $. The second PHP statement ends with;, which may not suit ASP programmers. These two omissions are where most errors in the program lie.
5. Operation symbols:
Mathematical operations:
symbol meaning
+
Addition
-
Subtraction
*
Multiplication
/
Division operation
%
Take the remainder
++
Accumulate
--
Decrement
String operation: There is only one operator symbol for
, which is the English period. It can concatenate strings into new merged strings. Similar to &
<? $a = "PHP 4" ; $b = "功能强大" ; echo $a.$b; ?>
in ASP, this also leads to two questions. First, the output statement in PHP is echo. Second, it is similar to in ASP. In PHP, Can=variable?>.
Logical operations:
Symbol Meaning
greater than
=
greater than or equal to
==
equal to
!=
not equal to
&&
And
and
And
Or (Or)
or
Or
xor
Xor
!
Not
That’s it for today, let’s talk about process control tomorrow.
The next day
Learning purpose: Master the process control of PHP
1. If..else loop has three structures
The first is to only use the if condition and treat it as a simple judgment. Interpreted as "what to do if something happens". The syntax is as follows:
if (expr) { statement }
Among them, expr is the condition for judgment, and logical operation symbols are usually 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.
<?php 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.
<?php if ($state==1) { echo "哈哈 ; echo "<br>" ; } ?>
The second type is that in addition to if, an else condition is added, which can be interpreted as "what to do if something happens, or how to solve it otherwise". 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.
<?php if ($state==1) { echo "哈哈" ; echo "<br>"; } else{ echo "呵呵"; echo "<br>"; } ?>
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
<?php if ( $a > $b ) { echo "a 比 b 大" ; } elseif ( $a == $b ) { echo "a 等于 b" ; } else { echo "a 比 b 小" ; } ?>
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.
<?php for ( $i = 1 ; $i <= 10 ; $i ++) { echo "这是第".$i."次循环<br>" ; } ?>
3、 switch 循环,通常处理复合式的条件判断,每个子条件,都是 case 指令部分。在实作上若使用许多类似的 if 指令,可以将它综合成 switch 循环。 语法如下 switch (expr) { case expr1: statement1; break; case expr2: statement2; break; default: statementN; break; } 其中的 expr 条件,通常为变量名称。而 case 后的 exprN,通常表示变量值。冒号后则为符合该条件要执行的部分。注意要用 break 跳离循环。
<?php switch ( date ( "D" )) { case "Mon" : echo "今天星期一" ; break; case "Tue" : echo "今天星期二" ; break; case "Wed" : echo "今天星期三" ; break; case "Thu" : echo "今天星期四" ; break; case "Fri" : echo "今天星期五" ; break; default: echo "今天放假" ; break; } ?>
这里需要注意的是break;别遗漏了,default,省略是可以的。
很明显的,上述的例子用 if 循环就很麻烦了。当然在设计时,要将出现机率最大的条件放在最前面,最少出现的条件放在最后面,可以增加程序的执行效率。上例由于每天出现的机率相同,所以不用注意条件的顺序。
今天就说到这里,明天开始说数据库的使用。

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

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.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1
Easy-to-use and free code editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),