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)06/03 Report--
This article mainly introduces "introduction to basic grammar of PHP". In daily operation, I believe many people have doubts about the introduction of basic grammar of PHP. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts of "introduction to basic grammar of PHP"! Next, please follow the editor to study!
Before you get started with the basic syntax of PHP, make sure that you install and configure the runtime environment for PHP.
1. How to embed PHP in HTML?
PHP as a WEB development technology, can be embedded in HTML to run, see the following example.
In the above example, the PHP code begins and ends with the PHP tag, which is used to tell the WEB server where to start and where to end the PHP code. There are four kinds of tags for PHP:
XML style:
The markup style recommended by PHP. This style can be used in XML (Extensible markup language) documents.
Short style:
This markup style is the simplest, and I usually use it. If it is off, you can find the short_open_tag option in the php.ini configuration file and set it to On.
SCRIPT style:
< script language= "php" >... < / script >
This kind of markup is probably not unfamiliar if you have used JavaScipt or VBScript. If you cannot support other markup styles in the HTML editor, you can use it.
ASP style:
This style also needs to be set in the php.ini configuration file to change the asp_tags option to On, which is turned off by default. This is designed to get used to ASP or ASP.NET programming style.
II. PHP statement
PHP statements, like C language, are separated by semicolons. Friends who are accustomed to Javascript programming must not forget that PHP statements must end with semicolons. Missing semicolons is a common syntax error.
Special case: when embedding PHP in HTML, for example, if you need to output a variable separately, you can directly use the echo statement in addition to the normal echo statement
It is equivalent to the function of the echo statement, and there is no need to end with a semicolon.
III. Notes
PHP supports C, C++ and shell script style comments
C style multiline comments
/ * Title:PHP basic Grammar Learning Keyword:PHP getting started Learning Author:David * /
Multiline comments start with "/ *" and end with "* /". Multiline comments cannot be nested.
C++ style single-line comments
Echo "Title:PHP basic Grammar Learning"; / / Title: basic Grammar Learning
Shell script style single-line comments, starting with #
Echo "Title:PHP basic Grammar Learning"; # Title:PHP basic Grammar Learning
IV. Connection between strings and variables
In PHP statements, when a statement needs to output the values of multiple variables or strings, you can use ".", that is,
Echo "Title:". PHP basic Grammar Learning
Error suppressor @
Mainly used to suppress some alarms, can be used in functions and other places, such as
$test = @ (1amp 0)
If there is no @, a warning alarm will be reported. If there is an alarm, it needs to be handled. If you use PHP5, you can throw an exception and then handle it, or you can activate the track_errors option in the php.ini configuration file and set it to On, so that the error message can be saved in the global variable $php_errormsg. Detailed explanation of PHP error report
VI. Execute operator
That is, reverse single quotes'', which is on the same key as ~, PHP will try to execute commands between reverse single quotes as server commands, as shown in
$output = `dir c: `; echo ". $output."
This statement is used to output the directory structure of disk c.
Special note: if the shell_exec () function is disabled, the above code will report an error message: shell_exec () has been disabled for security reasons, the solution is to find the php.ini configuration file, find the disable_functions option, remove shell_exec and restart Apache.
At this point, the study of "introduction to PHP basic Grammar" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.