Home >Backend Development >PHP Tutorial >The basics of PHP syntax that front-end must learn, front-end PHP syntax_PHP tutorial

The basics of PHP syntax that front-end must learn, front-end PHP syntax_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 09:01:55921browse

The basics of PHP syntax that front-end must learn, front-end PHP syntax

Written in front

PHP is a powerful server-side scripting language for creating dynamic and interactive sites. PHP can contain text, HTML, CSS and PHP code, execute it on the server, and the result is returned to the browser as plain text

Code identification

PHP code starts with d8ffb846d46b53fd10414594b13d7eb6, and can be placed anywhere in the document

<&#63;php
//
&#63;>

PHP statements end with a semicolon (;), and the closing tag of a PHP code block will automatically indicate the semicolon

<&#63;php
echo "Hello World!";
&#63;>

Notes

PHP supports three types of comments, including two single-line comments and one multi-line comment

<&#63;php
// 这是单行注释
#这也是单行注释
/*
这是多行注释块
它横跨多行
*/
&#63;>

Output

In PHP, there are two basic output methods: echo and print

print can only output a string and always returns 1

Echo can output more than one string. Echo is slightly faster than print because it does not return any value.

 Friendly reminder between scripts: echo and print are both language structures. You can use echo or echo() with or without parentheses, and print or print(), and echo or print There must be at least one space

between the keyword and the string
<&#63;php
echo "<h2>PHP is fun!</h2>";
echo "Hello world!<br>";
echo "I'm about to learn PHP!<br>";
echo "This", " string", " was", " made", " with multiple parameters.";
&#63;>
<&#63;php
print "<h2>PHP is fun!</h2>";
print "Hello world!<br>";
print "I'm about to learn PHP!<br>";
//该行出错,因为print只能输出1个字符串
print "This", " string", " was", " made", " with multiple parameters.";
&#63;>

Calculation expression

Unlike HTML and CSS, you can write calculation expressions in PHP

<&#63;php
//36
echo 12*3;
&#63;>

Case

In PHP, all user-defined functions, classes and keywords are not case-sensitive, but all variables are case-sensitive

<&#63;php
//Hello World!
ECHO "Hello World!<br>";
//Hello World!
echo "Hello World!<br>";
//Hello World!
EcHo "Hello World!<br>";
&#63;>

 Bangkejia kindly reminds everyone to pay attention to : . sign represents string connection. In other programming languages, the sign

is generally used
<&#63;php
$color="red";
//My car is red
echo "My car is " . $color . "<br>";
//My house is 
echo "My house is " . $COLOR . "<br>";
//My boat is
echo "My boat is " . $coLOR . "<br>";
&#63;>

The above content is the basic PHP syntax that the editor has shared with you. I hope it will be helpful to you. At the same time, I would like to thank you for your continued support of the Bangkejia website. I also wish you all a happy New Year. !

Articles you may be interested in:

  • PHP basic syntax format
  • How to check whether there are syntax errors in PHP files in PHP
  • php trim removal Definition and syntax introduction of null characters
  • Configuring PHP web pages to display various syntax errors
  • Basic syntax summary of PHP regular expressions
  • Vim plug-in for PHP syntax automatic checking
  • Basics and variables of PHP syntax summary

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1087269.htmlTechArticleThe basics of PHP syntax that must be learned on the front end. If the front-end PHP syntax is written in front, PHP is a way to create dynamic interactive sites. A powerful server-side scripting language. PHP can contain text, HTML,...
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