Get the App
SLTechnology News&Howtos  ›  Development  › 

Beginners learn PHP

Shulou Source: shulou.com Published: 2022-06-03 09:01:09 10月04日 Update

This article mainly explains "beginners learn PHP", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "beginners learn PHP" bar!

Goal planning:

Through the first lesson, we can understand the php environment.

1. Understanding of the environment:

two。 Access method:

3. Modify the code and view it.

4. The use of variables

5. Code indentation should be hierarchical, and it is best to leave blank lines between code

6. Variable naming:

7. Output of the variable:

8. There are three methods for variables:

1. Understanding of the environment:

Software download address: https://www.jb51.net/softs/24445.html

The installation tutorial is very simple. You can have a look at Baidu yourself.

Directory structure after installation:

two。 Access method:

Enter: localhost directly in the browser to access

3. Modify the code and view it.

We can modify the index.php in the directory www above

Php output html code:

Suggested writing method

4. The use of variables

5. Code indentation should be hierarchical, and it is best to leave blank lines between code

6. Variable naming:

6.1. Try not to use Chinese

6.2. Try not to start with a number.

6.3. Try not to use meaningless letters.

6.4. Variable names are case-sensitive, function names are not case-sensitive, and class names are not case-sensitive, simply variable names and function case-insensitive.

6.5. The definition of a variable must add $

7. Output of the variable:

Echo $name

8. There are three methods for variables:

Echo ($name); / / output variables

Var_dump ($name); / / output the array and print the type and length

Print_r ($name); / / output array

Example:

Display as follows

From the above display, we can see that the display is very unattractive and does not need to be read, so format the output scheme:

The display results are as follows:

A little knowledge:

When Utf-8 is encoded, a Chinese character is 3 characters.

When gbk is encoded, one Chinese character is 2 characters.

Thank you for your reading, the above is the content of "beginners learn PHP", after the study of this article, I believe you have a deeper understanding of the problem of beginners learning PHP, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Variables learning code output beginners methods size environment no between content functions characters hierarchies arrays best directories knowledge blank lines coding Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Information NVidia Shulou Technology MariaDB