Home > Article > Backend Development > The first day of learning PHP in ten days_PHP tutorial
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 complete. 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".
Here is a brief introduction to the syntax of PHP.
1. Embedding method:
Similar to ASP's <%, PHP can be , of course you can also specify it yourself .
2. Reference files:
There are two ways to reference files: require and include.
The usage method of require is 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. Comment method:
echo "This is the first example. n" ; // This example is a comment on C++ syntax
/* This example uses multi-line
comment */
echo "This is the second example. n" ;
echo "This is the third example. n" ; # This example uses UNIX Shell syntax comments
?>
4. Variable type:
$mystring = "I am a string";
$NewLine = "Newline n";
$int1 = 38;
$float1 = 1.732;
$float2 = 1.4E+2;
$MyArray1 = array( "子" , "Chou" , "寅" , "卯" ) ;
This raises two questions. First, PHP variables start with $, and second, PHP statements end with;. ASP programmers may not adapt. These two omissions are where most errors in the program lie.
5. Operation symbols:
Mathematical operations: Symbol meaning
+ Addition operation
- Subtraction operation
* Multiplication operation
/ Division operation
% Get remainder
++ Accumulation
-- Decrement
String operation:
There is only one operation symbol, which is the English period. It can concatenate strings into new merged strings. Similar to &
in ASP
$a = "PHP 4" ;
$b = "Powerful" ;
echo $a.$b;
? >
This also raises two questions. First, the output statement in PHP is echo. Second, it is similar to <%=variable%> in ASP. In PHP, it can also be = variable? >.
Logical operation:
Symbol meaning
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
== Equal to
!= Not equal to
&& And (And)
and And (And)
|| Or (Or)
or Or (Or)
xor Exclusive OR ( Xor)
! Not (Not)
That’s it for today, let’s talk about process control tomorrow.