Home  >  Article  >  what is php

what is php

PHPz
PHPzOriginal
2018-11-12 21:19:0791619browse

PHP is the abbreviation of Hypertext Preprocessor recursion. It is a widely used general-purpose open source scripting language, especially suitable for Web website development. It can be embedded in HTML and is one of the most widely used programming languages. PHP It is also easy to learn for beginners.

what is php

#PHP is one of the most widely used programming languages. PHP is also easy to learn for beginners. This is a language worth learning for those who want to learn programming for a career in the networking industry and for those considering career advancement.

This time, we will explain in detail what is PHP? What can it be used for? And an introduction to basic grammatical structures!

What is PHP?

First of all, what kind of language is PHP? To understand PHP, it is best to refer to PHP's official website php.net or php Chinese website php.cn. Let’s take a closer look.

PHP (PHP: Hypertext Preprocessor recursive abbreviation) is a widely used general-purpose open source scripting language, especially suitable for Web website development, and it can be embedded in HTML.

PHP is a scripting language that you can embed into HTML. A scripting language is a language that allows you to easily write programs using a programming language. Because the description method is close to English, it is easy to find even for beginners without computer science knowledge, and it is said to be easy to learn. In addition to PHP, JavaScript, Perl, Python, Ruby, etc. are included as scripting languages.

In C language, it is necessary to describe the command in order to display it in the browser, but PHP embeds the code in HTML and uses it. Therefore, it is easier to describe compared to C language.

PHP code is surrounded by 815b22acdbf9dab14aa760b8cd72f36d tags, and the descriptions between them are PHP instructions. [Recommendation:PHP Online Training Course]

8110d9d942ff468258e80bbe21d6e328 tag is called a php code termination directive.

What can PHP do?

What can be done in PHP?

1. Create a blog

Use PHP to create a blog wordpres, you can easily create a blog. You can use it even if you have no knowledge of PHP, but if you can write PHP you can customize your blog and create a theme.

2. Website development

60% of global Internet websites use PHP technology, and 80% of domestic Internet websites are developed using PHP. These websites include shopping websites, government enterprise websites, QQ space, forum blogs, etc.

3. Mobile microsite development and small programs

The popularity of mobile devices has laid the foundation for the rapid development of the mobile Internet! Mobile Taobao website, mobile JD website, etc., microsites in WeChat public account applications. In the future, microsites, official accounts, and mini programs will definitely replace APPs!

Using PHP, you will be able to build a variety of web services, not just the above. For more information, please refer to:What can the PHP language do?

What are the functions and advantages of PHP?

In PHP, it turns out that various services are used! So, what are the advantages of learning PHP? Let's summarize the commonalities.

1. Relatively simple

As mentioned above, PHP is said to be relatively easier to learn than other programming languages. The biggest obstacle to learning programming for inexperienced students is frustration. Learning to program is not easy. In order to minimize frustration, PHP has made some optimizations to make PHP an easy language to learn.

2. A large number of reference materials

PHP is one of the most used programming languages ​​in the world. Many people use it, so related information is also on the market. Many related PHP books have been published, and much related information is available on the Internet. If you are learning to program and encounter a problem, you can search for it. Reference information is quickly and abundantly available, which is a great advantage.

3. Widely used

80% of websites in China are developed using PHP language, including Baidu, Tencent, Taobao, Sina, Sohu, Meituan... ..Many are developed in whole or in part using PHP. Globally, WordPress, Facebook, Google, and YouTube are also built with PHP, and the rental space supports PHP, and the environment is configured. There are few cases where PHP cannot be used.

4. Recruiting more

The recruitment demand for PHP is high. According to a survey by Lagou.com, a professional IT recruitment website, the results show that the proportion of jobs in Java accounts for 30% of the total number of programming-related jobs, while the proportion of jobs in PHP accounts for 20% of the total. This ratio is expected to remain unchanged in the future, and PHP engineers have a stable job market. If you are considering a career change, php is a great choice!

How PHP works

What is the structure of PHP? How is it different from languages ​​like HTML and Javascript? To understand it, you need to understand the mechanics of PHP.

PHP is a server-side language. On the server, for requests sent from the web client, prepare data that matches the request and send the data back to the client. The data will be displayed on the client and will be displayed on the web.

PHP is responsible for transporting this server. On the other hand, since HTML and JavaScript are client-side languages, they do not communicate with the server. This is a huge difference between server-side languages ​​like PHP and client-side languages ​​like HTML and JavaScript.

Preparation for writing PHP

In order to test whether the script written in PHP works, you need to install the configuration server on your computer. This server is called the local server.

For Windows, it is recommended to install WampServer (WAMP). For Mac, it is recommended to install MAMP.

Basic PHP writing style

After we configure and install the PHP local environment, let us see how to write PHP code.

PHP can be described with HMTL code. See sample code below.



 Sample 


In this HTML code, we can find that a piece of code marked with 45d21ca01098d65392bc8103e357e88b (end command) is embedded in the middle of the 4a249f0d628e2318394fd9b75b4636b1 tag.

The code is as follows:

The print() function can output one or more strings, so for the above complete HTML code, we run it in the configured PHP local environment and browse When accessed by the server, you can see the words "Hello World" displayed.

Note: When writing PHP code, it must end with; (semicolon) before the end of the instruction mark, and you also need to add; (semicolon) at the end of each PHP instruction. ). Without the semicolon, the PHP code will not work properly.

If you want to access the results of your PHP code running in the browser, you need to save this file and view it. For files written in PHP, save the extension as ".php". For example, there is an "index.php" file here. We save it in the root folder of the server to see if it appears in Localhost. Just open localhost:80 (80 represents the port) in the browser.

The PHP development tools used

#The most commonly used are Notepad and SublimeText, as well as many similar PHP editors , the functions are similar, you can choose according to your own preferences. For specific tools, please go to: PHP development tool download channel

Basic syntax of PHP

Let’s introduce some common PHP syntax to you.

if else statement

The if statement is often used in programming. We define a conditional branch such as "if I do this, I will do this".

For example, the condition of the if statement in "If the password is entered correctly, if the login interface is entered, you can enter the next interface. If, when the password is incorrect on the login interface, an error message is displayed.", it means that we come and see.

<?php 
if(如果您可以在登录屏幕上正确输入密码){
//您可以进入下一个屏幕。
} 
else if(如果登录屏幕上的密码为空白){
//让我正确输入密码。
}
else {
//显示消息“密码错误”}
?>

By specifying the conditions, we will be able to respond to various assumptions.

for statement

In PHP, there are several syntaxes that specify iterative processing (called Loop in English). One of them is a statement.

In a loop, you can repeat the same code multiple times. However, if you don't determine the limit, if you just set iterations, the computer will continue to process it forever. Doing so will loop the computer and cause it to crash.

Repeat processing is very convenient, but please pay attention to its correct use. The repetition of the for statement is handled as follows. For example, let's write a for statement that displays a number between 1 and 100.

In () after "for", the conditions for iterative processing are defined. $i = 1; means the quantity is 1. $i <=100; means it is a number up to 100. In these two, we define numbers from 1 to 100. Finally, $i ; uses the (plus) sign to specify that the temporary number i will be added. If you want to subtract the number $i--;, use the minus sign.

while statement

Like the for statement, the while statement is a syntax for specifying iteration. The difference from the for statement is how to write the conditional statement. If the conditional statement specified in the while evaluates to true (true), the code in the while condition will be executed.

The sample code for writing a for statement using the while statement is as follows.

 

First, $i=1 defines the start of iterative processing. After $i we describe processing will continue until (100) is reached in "while" after (). Just like in the case of for statement, I command to add $i one by one and echo $i after that to show it.

There is another way to express it in the while statement. This is a... while statement. Doing this... The while statement is basically the opposite of the while statement. An example of writing a while statement using do...while statement is as follows.

基本上,显示与while语句相同的结果。但是,while语句和do..while语句之间的巨大差异发生在“不正确的条件(false)”。在while语句的情况下,条件定义首先出现,因此不执行条件之后的处理。另一方面,在do ... while语句的情况下,首先处理条件,因此首先进行处理。请根据场景正确使用。

总结:

这一次,我们介绍了PHP是什么,PHP语言学习的优点和基本语法。通过以上介绍您是不是觉得PHP对于初学者来说很容易学习!除了这次介绍的代码和语法之外,PHP还有很多东西需要学习,都比较容易理解学习。如果你对php感兴趣,可以参加我们的php培训公益课,让我们一起学习PHP吧!

相关推荐:

1. 前端学习路线:如何成为一名优秀的前端开发人员!
2. 编程学习入门教程

Statement:
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