PHP study notes

  • 2020-03-31 19:45:36
  • OfStack

Summary of PHP.
PHP, short for Hypertext Preprocessor, is a server-side, cross-platform, html-embedded scripting language with a unique syntax that blends the features of C, Java, and Perl. It is a widely used open source, multi-purpose scripting language.
Especially suitable for web development. PHP is a b/s architecture, a three-tier structure. After the service starts, the user does not need the corresponding client software, only the browser browsing can, which saves the graphical user interface, and greatly reduces the amount of application maintenance. PHP comes from free software, open source software,
Using PHP for web application development has the advantages of high security, cross-platform features, support for a wide range of databases, ease of learning, fast execution, low cost, templating, support for object-oriented, embedded Zend acceleration engine, stable and fast performance. Ranked no. 1 in the Tiobe world programming rankings
Third, the market share was 9.977%.
PHP extension library:
Starting with php5, the built-in standard extension library: XML extension library -dom, SimpleXML, SPL, SQLite, and libraries such as MySql, MySqlI, Overload, GD2 are placed in the external extension library of PECL and loaded first in the php.ini configuration file when needed. PHP search extension library
The default location in PHP5 is C: \ PHP5. To modify this to match the user's own PHP Settings, you need to edit the php.ini file: you need to modify the extension_dir setting to point to the directory where the user places the extension library or the php_*.dll file. For example: extension_dir = C
: \ \ PHP extensions; To enable an extension library in php.ini, you will want to load the semicolon before the extension library (;) by removing the annotation from the prefix of extension=php_*.dll in the line Delete, for example, to enable the Bzip2 extension library. Will the following code; The extension = php_bz2. DLL
As the extension = php_bz2. DLL;
Preliminary preparation:
1. Cornerstone of the development of HTML (Hypertext Markup Language)
2.Javascript, a client-side scripting language, can also be used to write scripts for execution on the server side.
Basic process of website construction:
Determine the website theme (main content: daqo profound) --> Collecting materials --> Planning website (structure, layout, color matching, style, etc.) --> Select development tool --> Make web pages (large before small [structure], simple before complex) --> Test site --> Upload website --> Promotion > d
Protect the update - > Determine the theme of your site.
PHP learning resources:
Development tools download website: / / www.jb51.net
PHP user manual official website: http://www.php.net
Common website resources:
Phpchina open source community: http://www.phpchina.com

How to learn PHP:
1. Be clear about your learning goals and broad directions.
2. Learn to configure the PHP development environment
3. Have a solid foundation of programming knowledge and familiar with common functions.
Understand design patterns.
5. Practice, think, and consult.
6. The most taboo to learn technology impatience, technical problems, must be calm.
7. Thousands of PHP functions, download a PHP Chinese manual and MySql manual.
8. Watch a lot of video and understand other people's programming ideas.
Develop good programming habits.
10. Don't give up when faced with problems. Be persistent and persistent.

PHP configuration is a bit complicated, last night the configuration of half a day did not succeed! We had to look for a simpler solution: a WampServer 5 integration environment

Wamp5 is an integrated environment of Apache+PHP+Mysql under Windows, with simple graphics and
Menu installation. This version integrates with PHP5.2.5 Mysql5 Apache2 phpMyAdmin 2.11.2.1
SQLiteManager 1.2.0 fulfills most of PHPer's requirements.

Syntactically, PHP is similar to C. It can be said that PHP is borrowed from the C language syntax features, by the C language to change
And so on. We can mix PHP code and HTML code, and not just embed PHP scripts into HTML
We can even embed HTML tags in PHP scripts. Here are a few ways you can do it.
You can choose the one that works best for you and stick to it!
Separate from HTML
Here are the methods you can use:

< ? ...? >

< ? PHP....? >

< Script language = "PHP" > ... < / script>

< %... %>

As with Perl and C, "; "is used in PHP. To separate statements. Flags that are separated from HTML also indicate the end of a statement.
annotation
PHP supports C, C, and unix-style annotation:


// C style single line comment

Unix-style single line comments

How to handle simple PHP errors:

1. You need to put display_errors in php.ini = On to display the error location

2. Get used to using echo or print

3. Learn to use comments to mask symbols for debugging
/ /...... .

#...

4, to understand the error message (English is not familiar with the Arabic numerals)

Basic PHP syntax and data types:
(1) basic PHP syntax:
1. HTM and PHP are mixed
2, a statement to; (end of semicolon)
3. How to define a variable and use it
(2)PHP data operation type
Four scalar types:
Boolean is understood as true or false
integer
Float (also called double)
Think of it as a decimal
string
Two compound types:
array
Object (object)
Boolean is understood as true or false

$bo = TRUE; $bo = FALSE;

integer

$bo = 1; $bo = - 12;

Float (also called double) is understood as a decimal

$bo = 1.001; $bo = 3.1415926;
string

$bo= "this string or EN Word";

array

$bo = array (1, 2, 3, 4); $bo = array (" A "= > 1, "B" = > 2);
Here is my first PHP program source code:
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title> The first one PHP The program </title> 
<style type="text/css"><!-- 
body,td,th { 
    font-size: 12px; 
} 
body { 
    margin-left: 10px; 
    margin-top: 10px; 
    margin-right: 10px; 
    margin-bottom: 10px; 
} 
--></style><style type="text/css" bogus="1">body,td,th { 
    font-size: 12px; 
} 
body { 
    margin-left: 10px; 
    margin-top: 10px; 
    margin-right: 10px; 
    margin-bottom: 10px; 
}</style></head> 
<body style="text-align:center" style="text-align:center"> 
    <span style="font-size:36px;color:blue;font-family: Chinese travel model " style="font-size:36px;color:blue;font-family: Chinese travel model "> Welcome to PHP The world!! !</span> 
<?php 
    $name="CHAUVET"; 
    $iValue="9999"; 
    $fValue=9.9900; 
    $bValue=true; 
    $aValue=array(1,2,3,4); 
    print "<br/>"; 
    echo "Hello world,"; 
    echo $name; 
    print "<br/>iValue  The value is "; 
    print $iValue; 
    print "<br/>iValue  The value is "; 
    print $fValue; 
    print $bValue; 
    print "<br/>bVlue  The judgment of the <br/>"; 
    if($bValue) 
    { 
        echo "bVlue The value is true"; 
    } 
    print "<br/>aVlue  The value is "; 
    for($i=0;$i<4;$i++) 
    { 
        echo $aValue[$i]; 
    } 

?> 
</body> 
</html> 

Introduction and application of common PHP operation types
1. Arithmetic operations
Ex. :

5 times 6 minus 12
2 * (28 + 1)

Note: arithmetic operation follows mathematical operation rules

From left to right, multiply and divide and then add and subtract
2. Assignment operation
Ex. :

$a = 1;
$a + = 2;
$a * = 3;

Note: assign the right value to the left variable.
3. Comparison operation
Ex. :

1 = = 2
3! = 2
5 < 3
"Ok" = = "ok"
1 = = = '1'

Note: the value obtained by the comparison operation is a Boolean value
4. Logical operation
Ex. :

1 & 1
0 && 1
1 | | 1
1 | | 0

5. Increment and decrement operation
Ex. :

$+
+ + $a
$a -
- $a


The PHP source code:
 
<title> The output form </title> 
<?php 
echo "<table border='1' width='300'>"; 
for($i=0;$i<4;$i++) 
{ 
echo "<tr>"; 
for($j=0;$j<4;$j++) 
{ 
echo "<td>"; 
echo $j+1; 
echo "</td>"; 
} 
echo "</tr>"; 
} 
echo "</table>"; 
?> 
<title> The output form </title> 
<?php 
echo "<table border='1' width='300'>"; 
    for($i=0;$i<4;$i++) 
    { 
        echo "<tr>"; 
        for($j=0;$j<4;$j++) 
        { 
            echo "<td>"; 
            echo $j+1; 
            echo "</td>"; 
        } 
        echo "</tr>"; 
    } 
echo "</table>"; 
?> 

Operator:
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>php The operator of </title> 
<style type="text/css"><!-- 
body,td,th { 
font-size: 12px; 
} 
body { 
margin-left: 10px; 
margin-top: 10px; 
margin-right: 10px; 
margin-bottom: 10px; 
} 
--></style><style type="text/css" bogus="1">body,td,th { 
font-size: 12px; 
} 
body { 
margin-left: 10px; 
margin-top: 10px; 
margin-right: 10px; 
margin-bottom: 10px; 
}</style></head> 
<body style="text-align:center" style="text-align:center"> 
<?php 
//Addition, subtraction, multiplication, and division are not available in that programming language
print (1+3)*5; 
echo "<br/>"; 
print (3-1)/10; 
print "<br/>"; 
//The assignment operation
$val=3; 
$val+=5;//Equivalent to $val = $val + 5
$val*=10; 
echo "val The value is: "; 
print $val; 
print "<br/>"; 
//Comparison operations
if(1==1&&5>3){print " Logic and a false are false <br/>";} 
if(3!=2||"ok"=="ok"){print " Logic or truth for truth <br/>";} 
 
$value=8; 
echo $value++;#8 Also note  
print "<br/>"; 
echo $value;#9 
print "<br/>"; 
print ++$value;#10 
echo "<br/>"; 
echo --$value;#9 
?> 
</body> 
</html> 

Related articles: