preface

As a programmer, we should all have heard such a phrase: THE PHP programming language, is the world’s most useful programming language ~~~ but today the leader told me to get out, I am not convinced to write this PHP introduction foundation hanged leader. Network security gift package

PHP, also known as the Hypertext preprocessor, is a general-purpose open source scripting language. PHP is mainly applicable to the Web development field, and its syntax has absorbed the characteristics of C language, Java and Perl, which is conducive to learning and widely used. Its unique syntax is a mixture of C, Java, Perl, and PHP’s own syntaxes. It can execute dynamic web pages faster than CGI or Perl. Compared with other programming languages, PHP is a program embedded in HTML documents to execute, execution efficiency is much higher than CGI completely generated HTML tags; PHP can also execute compiled code, which can be encrypted and optimized to make code run faster.

After understanding the basic concepts of PHP, the following share the basic knowledge of PHP, hope to help to learn PHP ~

First, PHP web foundation

One, static website & dynamic website

Static website :(pure HTML page, page fixed, will not change), no interaction with the back-end server, no database support. Dynamic website :(can dynamically display different content according to the interaction situation), need to interact with the background server for data, need to support the database.

Two, support dynamic website language

  • Java—JSP
  • PHP—-PHP
  • asp—-asp

Three, common servers

  • Apache:A server owned by Apache corporation that is used to parse PHP-like websites
  • Tomcat: Another Server owned by Apache, which is used to parse JSP class websites;

Four, common database

Mysql, Access, Oracle, essentially a… We usually match PHP to MySQL. Of course, PHP can connect to almost any major database.

5 C/S and B/S

  • B/S: Browser/server structure. A website that users can access only through a browser. Most of the operational functions are concentrated in the background server.
  • C/S: client/server structure. The user needs to install the program used by the client. The client can share certain operation functions.

Six, common development of PHP integration environment

The installation of a piece of software with multiple software or language environments built in

  • Wamp:windows+Apache+mysql+PHP
  • Lamp:Linux+Apache+mysql+PHP
  • PHPStudy:
  • APPServer:

Note: Linux is preferred for PHP development, but PHP is friendly and compatible with various operating systems.

(Windows, Linux, Unix, MacOS…)

Two, PHP entry foundation

“+” in PHP only has the function of calculating, not connecting. Connection functions connect with “.”. Key words: PHP: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false: false To use PHP syntax, you must put the PHP language in the markup. PHP supports the following four markup methods:

This is PHP official recommended writing method, is also our main use of writing method! The tag can be inserted anywhere in the HTML document;

Note: If the page has only PHP language, it is recommended to omit the end of the ‘? > ‘. Cause: If the terminating symbol is included, you may import extra newlines at the end of the file when importing the PHP file. This is always possible, but we don’t recommend it. ③ Short marking style. Ini file. You need to open short_open_tag = On. However, it is not recommended because it conflicts with markup in XML. ④<% %> ASA style. It is disabled by default. You need to open “asp_tags = On” in the php.ini file. However, it is not recommended because it conflicts with the tags in ASP and JSP.

Directive delimiters in PHP

1, PHP “structure definition statement” (branch, loop, class, function, etc. {} end), do not need to use semicolon end. Function execution statements in PHP must end with a semicolon if they do not end with {}. 3. Special case: End tag? The semicolon can be omitted from the last statement before >.

3. Variables in PHP

1, PHP variable, declaration and use, must use the beginning. PHP is a weakly typed language. You don’t need to declare variables. You can assign variables of any type to them directly. Eg: the beginning. PHP is a weakly typed language. You don’t need to declare variables. You can assign variables of any type to them directly. Eg: the beginning. PHP is a weakly typed language. You don’t need to declare variables. You can assign variables of any type to them directly. eg:num1 = num2=num2 = num2=num3 = 5; 4, common variable function: unset(); Delete and release variables; isset(); Verify that variables are set; empty(); Verify that the variable is null (if it is not set or null is null); 5. Variable name: Contains only digits, letters, and underscores, and cannot start with a number. Also, variables in PHP are case sensitive! Namename, namename, $NAME. However, PHP built-in function or class names are not case sensitive! Echo echo is valid! 4 scalar types in PHP

The Boolean Boolean
The integer Integer
floating-point Float/Double
string String

Two types of composite:

An array of Array
object Object

2 special types:

resources Resource
empty null

7. The integer type ranges from -2^31 to (2^31-1). If the integer type exceeds this range, the system automatically converts to floating point

False in PHP

1, Boolan false 2, integer 0 3, float 0.0 4, string “” “0” (“0.0” “000”) Only one 0 is wrong!) Empty objects are false only in PHP4. In other versions, objects count true. 7. Null and undefined variables 8. All resources count right! (Except for PHP4, all objects count correctly!!)

String declarations in PHP

$STR = <<<s(delimiter) // the delimiter starts with <<<(delimiter) // The delimiter ends with the top case!! No space!! // The delimiter can be any letter, as long as the beginning and end are the same! s; (Delimited identifier for the top case)

4, the difference between the three declaration methods: ① Delimiter function, the default is the same as double quotation marks. (But delimiters can put double quotation marks) (2) Single quotation marks cannot parse variables, while double quotation marks and delimiters can parse variables. Note: When parsing variables with double quotation marks, note that “hahaha{num}hahaha” or “hahaha{num}hahaha” is required after the variable name! (3) Single quotes can be enclosed with double quotes, and double quotes can be enclosed with single quotes. However, you cannot put quotes of the same type as yourself. (4) Escape characters cannot be used in single quotation marks (except for the single quotation mark “” itself, the escape character \ itself), but escape characters can be used in double quotation marks.

Pseudo types in PHP

Pseudo-type: not a real data type. It exists only to tell programmers which data types can be used, and is often used when writing help documents.

Mixed: Indicates that the parameter can be of multiple data types. Number: The parameter can be Integer or Float. Callback: the argument can be a callback function.

Data type conversion in PHP

1. Automatic type conversion: Null –>0 True –>1 false–>0 String Specifies the number before the conversion to a non-numeric character. “123a”–>123 “a123”–>0

2, cast: according to our needs, forced to convert variables into other types of variables. New variable =(new type) new variable =(new type) new variable =(new type) original variable; $str = (String)1; // New type. You can use full spelling or abbreviations. Integer/int Boolean/bool is fine.

The following types can be cast:

(int), (integer) Convert to integer
(bool), (Boolean) Convert to a Boolean
(float), (double), (real) Convert to floating point
(string) Convert to string
(array) Convert to an array
(object) Convert to object

(2) use setType (); Bool setType(mixed var,String type); The first argument represents a variable of any type, and the second argument represents a data type of string type, returning a Boolean result.

③ The difference between the two transformations:

  • The first: is to convert the results, assigned to a new variable;

  • ② : the data type of the original variable is changed directly.

Judge types in PHP

is_bool() Determine if it is a Boolean
Is_int (), is_integer(), and is_long() Determine whether the type is an integer.
Is_float (), is_double(), and is_real() Determine whether the type is floating point
is_string() Check whether it is a string
is_array() Check whether it is an array
is_object() Determine whether it is an object
is_resource() Check whether it is a resource type
is_null() Check whether the value is NULL
is_scalar() Determine whether it is a scalar
is_numeric() Determines whether it is a number of any type and a numeric string
is_callable() Check whether the function name is valid

Output statements in PHP

Echo “…” Output the value of the variable
var_dump(num) The data type & value of the output variable [& some other information]
print_r(arr) Used exclusively for printing arrays
// Single-line comments /** Multi-line comments */ /** * Document comments */Copy the code

3. Script comments

# echo "form";Copy the code

Constants in PHP

Bool define(String name,mixed constant value [,bool is case sensitive)); 2, constant note: ① Constant definition, can only use the define() function; In principle, constant names must be declared in uppercase. And it must be unsigned (sign (sign (only variables); After constant declaration, the default global scope is valid. There is no scope. ④ Constant not only can not change, and can not delete! 5) Constant is case sensitive by default!! However, you can declare constants by setting the third parameter define to true to make them case insensitive. ⑥ Constants must be defined using define(). If an undeclared constant is used, it defaults to a constant string. But there are caveats. var_dump(NUM); Boolean String Float Integer 3, echo constant(“NUM”); Read constant value! Attention!! You can use get_defined_constants() to get all the defined constants!! Contains N constants defined by the system.

I am a penetration testing engineer, and as a thank you to the readers, I would like to donate some of my network security/penetration testing learning tips to you, to give back to each and every reader, hoping to help you.

Dry goods are mainly:

① More than 2000 online security must-read e-books (mainstream and classic books should be available)

PHP standard Library data (the most complete Chinese version)

(3) project source code (forty or fifty interesting and classic practice projects and source code)

④ Network security basic entry, Linux operation and maintenance, Web security, penetration testing video (suitable for white learning)

⑤ Network security learning roadmap (farewell to the flow of learning)

⑥ Penetration test tools

⑦ 2021 Network security /Web security/penetration test engineer interview manual encyclopedia

Due to the limited space, the information is put in my personal document, if you need to click below to get it

To collect data

Finally, thank you for your attention and reading!!