Home  >  Article  >  Backend Development  >  PHP basic tutorial 1 php language basics php0 basics php basic practice

PHP basic tutorial 1 php language basics php0 basics php basic practice

WBOY
WBOYOriginal
2016-07-29 08:49:161172browse

What is a PHP file?

PHP files can contain text, HTML, CSS and PHP code
The PHP code is executed on the server and the results are returned to the browser as plain text
The suffix of PHP files is “.php”


What can PHP do?

PHP can generate dynamic page content
PHP can create, open, read, write, delete and close files on the server
PHP can receive form data
PHP can send and retrieve cookies
PHP can add, delete, and modify data in the database
PHP can restrict users from accessing certain pages in the website
PHP can encrypt data
With PHP you are not limited to just outputting HTML. You can also export images, PDF files, and even Flash movies. You can also output any text, such as XHTML and XML.


PHP supports three types of annotations:

<html><body>// 这是单行注释# 这也是单行注释/*
这是多行注释块
它横跨了
多行
*/?>body>html>

PHP Case Sensitive

In PHP, all user-defined functions, classes and keywords (such as if, else, echo, etc.) are not case sensitive.
In the following example, all three echo statements are legal (equivalent):
Example

<html><body>ECHO"Hello World!
"
; echo"Hello World!
"
; EcHo"Hello World!
"
; ?>
body>
html>

Hello World!
Hello World!
Hello World!


But in PHP, all variables are case-sensitive.
In the example below, only the first statement will display colorchange Amount of worth( This is Because is color, CO LOR to and coLOR are treated as three different variables):
Example

<html><body>$color="red";
echo"My car is " . $color . "
"
; echo"My house is " . $COLOR . "
"
; echo"My boat is " . $coLOR . "
"
; ?>
body>
html>

My car is red
My house is
My boat is


PHP 5 echo and print statements

PHP echo and print statements

The difference between echo and print:
echo - can output more than one string
print - can only output one string, and Always returns 1
Tip: echo is slightly faster than print because it doesn't return any value.

PHP echo statement
echo is a language construct that can be used with or without parentheses: echo or echo().

<html><body>echo"

PHP 很有趣!

"
; echo"Hello world!
"
; echo"我计划学习 PHP!
"
; echo"这段话", "由", "多个", "字符串", "串接而成。"; $txt1="Learn PHP"; $txt2="W3School.com.cn"; $cars=array("Volvo","BMW","SAAB"); echo$txt1; echo"
"
; echo"Study PHP at $txt2"; echo"
"
; echo"My car is a {$cars[0]}"; ?>
body>
html>

Hello world!
I plan to learn PHP!
This paragraph is composed of multiple strings concatenated.
Learn PHP
Study PHP at W3School.com.cn
My car is a Volvo

PHP print statement
Print is also a language construct and can be used with or without parentheses: print or print().

<html><body>print"

PHP is fun!

"
; print"Hello world!
"
; print"I'm about to learn PHP!"; $txt1="Learn PHP"; $txt2="W3School.com.cn"; $cars=array("Volvo","BMW","SAAB"); print$txt1; print"
"
; print"Study PHP at $txt2"; print"
"
; print"My car is a {$cars[0]}"?>
body>
html>

PHP is fun!

Hello world!
I’m about to learn PHP!
Learn PHP
Study PHP at W3School.com.cn
My car is a Volvo

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced PHP basic tutorial 1, including PHP and basic aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

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