In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
What are the knowledge points of this article "PHP basic grammar, variables and constants?" most people do not understand, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "PHP basic grammar, variables and constants knowledge points" article.
Foreword:
PHP, known as hypertext preprocessor in Chinese, is a general open source scripting language. Grammar absorbs the characteristics of C language, Java and Perl, which is convenient for learning and widely used. It is mainly suitable for the field of Web development. Dynamic pages made with PHP compared with other programming languages, PHP is to embed the program into HTML (an application under the standard general markup language) documents to execute, the execution efficiency is much higher than the complete generation of HTML tags CGI; PHP can also execute compiled code, compilation can achieve encryption and optimize the code to run, so that the code runs faster.
Basic Grammar (1) language Marker
Basic tag:
Short mark:
Script tags: PHP cod
ASP tag:
Note: pure PHP script files recommend the use of unclosed basic tags: they imply a semicolon, so the last line of PHP code can be done without a semicolon! All suggestions are added.
(3) Notes (4) the difference between HTML and PHP
PHP is an upgraded form of the HTML language, and the language structure still takes HTML as the core; HTML is a markup language for specifying web content, and PHP is a scripting language
Pages created with HTML are static pages, while PHP files can create dynamic pages, and PHP files can contain text, HTML tags, scripts, and so on.
HTML is a string for PHP, while HTML is output directly as a string in the PHP language; and the HTML tag, as a separate tag, can be written outside the PHP tag!
(5) PHP line break
"" browser display line wrap, source code display
The "\ n" browser does not display line breaks, while the source code shows line breaks
(6) difference between 'echo'' and 'print'' echo commands
Echo supports multiple string outputs, separated by commas (,). Print supports only one string output.
Echo output speed is faster than print.
Print () has a return value, which is successful. The return value is 1 false, and the return value is 0, while echo has no return value.
Summary: try to use echo when writing code, because it supports multiple string output. If you insist on using print, I can't stop you, but you can only output one string, but don't drink too much.
(7) keywords
Words that are pre-defined and given a special meaning in a programming language are also called reserved words. Like other languages, PHP retains many keywords, such as class, public, and so on.
Note: ★ means to start from PHP5.3, ● means to start from PHP5.4, and ▲ means to start from PHP5.5
(8) illustration of basic grammar examples
Variable types (data types) (1) Classification
(2) Integer
Rules
An integer must have at least one number (0-9)
Integers cannot contain commas or spaces
Integers cannot have decimal points
Integers can be positive or negative
Three formats specify integers: decimal, hexadecimal (prefix 0x) or octal (prefix 0)
(3) floating point type
A floating point number is a number that has a decimal point or an exponential form.
(IV) Boolean type $a = true;$a = false; (v) string type
Note when defining a string:
Single quotation mark ``: the internal content is only as a string.
Double quotation marks "": if the inside is a variable of PHP, the value of that variable will be parsed. If the html code is inside, it will also be parsed to html.
(6) Array type
The array stores multiple values in a variable.
(7) Special data type-NULL
A special NULL value indicates that the variable has no value. NULL is the only possible value of the data type NULL. The NULL value indicates whether the variable is empty. It is also used to distinguish between empty strings and null databases.
Constant (1) the difference between constant and variable
The constant is not preceded by a dollar sign ($)
Constants can only be defined with the define () function, not through assignment statements
Constants can be defined and accessed anywhere regardless of the rules of variable scope
Once a constant is defined, it cannot be redefined or undefined
The value of a constant is usually of type bool,int,float,string
(2) predefined constants
A constant that PHP has defined and can be used directly generally represents a special meaning.
System constant: PHP_VERSION,PHP_INT_MAX,PHP_INT_SIZE
Magic constant: _ _ DIR__,__FILE__,__LINE__,__CLASS__,__METHOD__,__NAMESPACE__
The above is the content of this article on "what are the knowledge points of PHP basic grammar, variables and constants". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.