The first day of learning PHP in 10 days

web front end four thousand eight hundred and sixty-seven 13 years ago (2011-04-08)

I wrote for ten days to learn ASP I learned ASP.NET in ten days. Now I want to write PHP again. I won't mention PHP debugging methods here. Many articles have introduced PHP debugging methods, and there are many different combinations. I temporarily use Apache web server and MY SQL as the WEB The server and data base , in the environment of php 4.3.3. Of course, it is necessary to simply build and access the database PHPMYADMIN.

As for form design, I don't want to say much here.

Here is a brief introduction to PHP syntax.

1. Embedding method:

Similar to ASP's<%, PHP can be a? Php or<?, The ending symbol is?>, Of course, you can specify it yourself.

2. References:

There are two ways to reference files: require and include.
The use method of require is as follows: require ("MyRequireFile. php"). This function is usually placed at the front of the PHP program. Before the PHP program executes, it will first read in the file specified by require to make it part of the PHP program web page. Common functions can also be introduced into web pages in this way.

Use methods of include, such as include ("MyIncludeFile. php"). This function is usually placed in the processing part of process control. The PHP program web page will read the include file when it reads it. In this way, the process of program execution can be simplified.

3. Annotation method:

PHP code
  1. <? php    
  2.    echo   "This is the first example. n"  ;   //This example is a comment on C++syntax   
  3.    /*This example uses multiline  
  4. Annotation method*/     
  5.    echo   "This is the second example. n"  ;     
  6.    echo   "This is the third example. n"  ; #This example uses UNIX shell syntax comments
  7. ?>   

4. Variable type:

PHP code
  1. $mystring  =  "I am a string"  ;     
  2. $NewLine  =  "Wrapped n"  ;     
  3. $int1  = 38 ;     
  4. $float1  = 1.732 ;     
  5. $float2  = 1.4E+2 ;     
  6. $MyArray1  =  array Child  ,  Ugly  ,  Yin  ,  "Mao"  );    

Two problems arise here. First, PHP variables begin with $, and second PHP statements begin with; At the end, ASP programmers may not adapt. These two omissions are also the source of most errors in the program.

5. Operation symbol:

Mathematical operation: symbolic meaning
+Addition operation
-Subtraction
*Multiplication
/Division operation
%Remainder
++Accumulation
--Decreasing

String operation:

There is only one operation symbol, that is, the English full stop. It can concatenate strings into new merged strings. Similar to that in ASP&
 

PHP code
  1. <?   
  2. $a  =  "PHP 4"  ;     
  3. $b  =  "Powerful"  ;     
  4. echo   $a . $b ;     
  5. ?>   


Two problems also arise here. First, the output statement in PHP is echo. Second, similar to<%=variable%>in ASP, PHP can also
 

PHP code
  1. <?= Variables?>   

Logical operation:

Symbolic meaning
<less than
>Greater than
<=less than or equal to
>=Greater than or equal to
==Equals
    != Not equal to
&&And
And
||Or
Or or (Or)
Xor
    ! Not

That's all for today. Let's talk about process control tomorrow.