Home > Backend Development > PHP Tutorial > What programming novices must know to learn PHP

What programming novices must know to learn PHP

烟雨青岚
Release: 2023-04-08 21:56:01
forward
2331 people have browsed it

What programming novices must know to learn PHP

Things that beginners in programming must know when learning PHP

1. What is a computer program?

Excerpt from an encyclopedia description: Computer program, also known as software, referred to as program, refers to a set of instructions for a computer or other device with information processing capabilities. The instructions for each action are usually written in a certain programming language and run on a certain target architecture.

Popular understanding of computer programs

A computer program is a set of instructions that can be run on a computer to complete specific functions. The complexity of a computer program is determined by the logical functions that need to be completed. Computer programs range from simple to complex. For example, writing a simple program can calculate the solution to a quadratic equation, while a powerful game program can bring you a different gaming experience. The essence of the program is to run A set of ordered instructions on a computer. These instructions allow the computer to perform some specific operations and achieve specific functions.

After the computer is turned on and the operating system is entered, such as Windows/Linux/Mac, etc., the operating system will load and execute many programs. The essence of the operating system is also composed of a set of computer programs, which are generally expressed as computer programs. , generally refers to a relatively independent program that can complete certain specific functions, such as video/audio player, web browser, social tool client Wechat/QQ, etc.; and generally many computer programs work together to complete the comparison A series of programs that perform complex tasks, often called a system, such as an operating system.

The instructions mentioned in the encyclopedia description run on a certain target architecture. For most computers, from the perspective of the broad classification of computer architecture, the target architecture here usually refers to the most The common von Neumann architecture is the basic structure of the computer described in the previous section. Under the von Neumann architecture design, the design of the CPU (calculator and controller) can also be divided into different architectures. .

Let’s learn more about what an instruction set is. An instruction set is a hard program stored inside the CPU that guides and optimizes CPU operations. That is to say, the CPU’s arithmetic unit can only execute the CPU’s instruction set. The instructions supported by the system have different CPU architectures because the design of the instruction set is different. Common CPU architectures include Intel's X86 architecture and ARM's ARM architecture. The corresponding instruction sets are Complex Instruction Set (CISC). ) and reduced instruction set (RISC), the main difference between X86 and ARM processors is that the former uses complex instruction set (CISC), while the latter uses reduced instruction set (RISC). X86 architecture CPUs are commonly found in notebooks, desktops and servers, while ARM architecture CPUs are mostly used in mobile phones and embedded systems. There are many subdivisions of instruction sets. If you are interested, you can learn more about them.

2. What is a programming language?

The above describes what a computer program is. The essence of a computer program is a set of instructions running on a certain target architecture (which can be temporarily understood as a certain CPU architecture), and these instructions The set of should be supported by the CPU architecture, that is, the CPU's arithmetic unit can execute all instructions in the instruction set. That is to say, when programs with the same function are written on different CPU architectures, the finally generated program corresponds to The set of instructions is likely to be different.

1. Machine language

Thousands of programs can be written through the instruction set supported by the CPU architecture, and the instruction set The composed program can be directly interpreted and executed by the CPU. The process of generating a program from the instruction set is like writing an article through text. A single word or word is a specific instruction. Different words or words (instructions) pass through certain The combination of rules is an article (program), so the instruction set system supported by the CPU architecture can also be regarded as a language. This language is commonly known as machine language, also known as machine code. The different instruction sets supported by different CPU architectures can be regarded as different machine languages. Just like text is also divided into many languages ​​such as Chinese and English, the same is true for machine languages.

2. Assembly language

You can write many programs with various functions through machine language, but when writing programs in machine language, programmers must first memorize them All the instruction codes of the computer used and the meaning of the codes. When hand-programming, the programmer also needs to handle the storage allocation and input and output of each instruction and each data. He also has to remember the work units used in each step of the programming process. In what state. This is a very tedious job. The time it takes to write a program is often dozens or even hundreds of times longer than the actual running time. Moreover, the programmed programs are all instruction codes of 0s and 1s, which are not intuitive and prone to errors. So what should we do?

At this time, assembly language came into being. The main body of assembly language is assembly instructions. The difference between assembly instructions and machine instructions lies in the expression method of instructions. Assembly instructions are machine instructions in a writing format that is easy to remember. For example, to perform an operation: the contents of register BX are sent to AX (you don’t need to go into the specific meaning, you understand that it is a complete Instructions for specific functions are enough)

  1000100111011000               机器指令
    mov ax,bx                    汇编指令
Copy after login

It is easy to see that for the same operation, the following assembly instructions are easier to remember. The emergence of assembly language is a major progress in the development of programs. Compared with machines The language mainly has the following features:

1. It is more programmable, that is, using assembly language, programmers can be simpler, faster and easier Complete the same programming task in an understanding way;

2. Program portability, as introduced above, different CPU architectures support different instruction set systems (machine languages), so usually Programs written in machine language for a certain type of CPU architecture cannot run on other CPU architectures. With assembly language, you can imagine that the same assembly statement only needs a compiler to compile it when running on different CPU architectures. (Just like translation between different languages) into machine code supported by the corresponding CPU architecture;

The assembly language compiler is a program that can translate assembly language into machine language on the target CPU architecture .

3. High-level language

We learned previously what machine language and assembly language are. Assembly language is the same as machine language, and it directly operates the hardware. However, assembly language instructions use English abbreviated identifiers, which are easier to recognize and remember, but they are only relative to machine language. In actual programming, assembly language source programs are also very complex and lengthy. In order to write programs more simply and efficiently, high-level languages ​​came into being.

High-level language does not refer to one language, but includes many programming languages, such as C, C, Java, php, python, etc., which are highly encapsulated programming languages. High-level languages ​​have nothing to do with the computer's hardware structure and CPU architecture (instruction system). Assembly language already has a certain degree of portability. The compiler can translate it into the corresponding machine language according to the corresponding CPU architecture. Similarly, high-level languages ​​are more portable. Strong, the compiler can also translate high-level language into machine language on the target CPU architecture. Whether it is directly translated into machine language, or first compiled and then translated into machine language, depends on the implementation of the compiler.

Nowadays, we generally don’t need to learn how to use machine language or assembly language to program. We only need to know how to understand assembly language. When the high-level language we write is translated into the target language, the compiler will automatically perform some optimization processing.

4. Classification of high-level languages

There are many ways to classify high-level languages. According to the characteristics of design ideas, they can be divided into process-oriented (imperative) ) languages, object-oriented languages, functional languages ​​and logical languages, and are divided into two categories according to the time when the code is translated before execution: interpreted languages ​​and compiled languages.

Process-oriented (imperative) language

The semantic basis of this language is a Turing machine that simulates "data storage/data operation" Computable models are very much in line with the natural implementation of modern computer architectures. The main way to generate operations is to rely on the side effects of statements or commands. Most modern popular languages ​​are of this type, such as Fortran, Pascal, Cobol, C, C, Basic, Ada, Java, C#, etc. Various scripting languages ​​are also considered to be of this type.

Object-oriented languages

Most modern languages ​​provide object-oriented support, but some languages ​​are built directly on the basic object-oriented model , the semantics of the grammatical form of the language are basic object operations. The mainstream languages ​​that support object-oriented programming include C, Java, C#, PHP, Python, etc. General languages ​​also support process-oriented (imperative) programming.

Functional Language

The semantic basis of this language is the lambda operator computable model of value mapping based on the concept of mathematical functions. This language is very suitable for calculations for work such as artificial intelligence. Typical functional languages ​​such as Lisp, Haskell, ML, Scheme, F#, etc.

Logical language

The semantic basis of this language is a formal logic system based on a set of known rules. This language is mainly used in the implementation of expert systems. The most famous logical language is Prolog.

Although various languages ​​belong to different types, they each support the operation modes of other types of languages ​​to varying degrees.

5. Interpreted Language

Interpreted language can be divided into: markup language and scripting language based on the active and passive characteristics of the language. Markup languages ​​passively wait for interpretation and do not actively issue instructions to the computer. Scripting languages ​​generally actively issue instructions for the computer to perform tasks.

Markup language

Markup language is a computer text encoding that combines text (Text) and other information related to the text to show details about the document structure and data processing. Other information related to the text (including the structure and presentation information of the text, etc.) is combined with the original text but identified using markers.

For example: xml, html, xhtml

Script language

Script language is to shorten the traditional writing process -A computer programming language created by the edit-compile-link-run process. It is named after a script "screenplay" that causes the dialog box to repeat itself verbatim each time it is run. Early scripting languages ​​were often called batch processing languages ​​or job control languages. A script is usually run interpreted rather than compiled. Scripting languages ​​usually have the characteristics of being simple, easy to learn, and easy to use. The purpose is to allow programmers to quickly complete program writing work.

For example: JavaScript, VBScript, PHP, Python

6. Compiled language

Compiled language : The program requires a special compilation process before execution. The program is compiled into a machine language file. There is no need to re-translate it when running. Just use the compiled result directly. The program execution efficiency is high, it relies on the compiler, and its cross-platform performance is poor.

For example: C, C, c#, java, etc.

7. The difference between different types of high-level languages

1. Markup language is not used to issue instructions to the computer, but is often used for formatting and linking.

2. Script language is between markup language and programming language. Script language does not need to be compiled and can be used directly. The interpreter is responsible for interpretation.

3. Before a program written in a compiled language is executed, a special compilation process is required to compile the program into a machine language file, such as an exe file. If it is to be run in the future, it does not need to be re-translated. Just use the compiled result (exe file) directly. Because the translation is only done once and no translation is needed during runtime, the execution efficiency of compiled language programs is high.

8. General characteristics of high-level languages

1. High-level languages ​​are close to algorithmic languages, easy to learn and master, and only require general engineering and technical personnel A few weeks of training can make you competent as a programmer;

2. High-level languages ​​provide programmers with a structured programming environment and tools, making the designed programs more readable. High maintainability and high reliability;

3. High-level language is far away from machine language and has nothing to do with the computer's hardware structure and instruction system. It has stronger expressive ability, so the program written can Good portability and high reuse rate;

4. Since the complicated and trivial matters are handed over to the compiler, the degree of automation is high, the development cycle is short, and programmers are relieved and can concentrate Time and energy are spent on creative work that is more important to them to improve the quality of the program;

5. The program code generated by high-level language compilation is generally better than the program code designed in assembly language It is long and the execution speed is also slow. Therefore, assembly language is suitable for writing programs that require high speed and code length and programs that directly control hardware. High-level language programs "cannot see" the hardware structure of the machine and cannot be used to write system software or device control software that directly accesses machine hardware resources. . To this end, some high-level languages ​​provide calling interfaces with assembly language. A program written in assembly language can be used as an external procedure or function in a high-level language, using the stack to pass parameters or the address of parameters.

Thank you everyone for reading, I hope you will benefit a lot.

Original link: https://blog.csdn.net/abc_1225/article/details/80237929

Recommended tutorial: "PHP Tutorial"

The above is the detailed content of What programming novices must know to learn PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template