In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you what the basic grammar of PHP, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
PHP environment installation:
The usual combination of PHP is: MySql+PHP+Apche also has IIS+PHP+MySQL or SqlServer
Of course, we can choose the combination package to install. Beginners suggest installing AppServ or phpnow, etc.
Under iis, you can run it with this installation to support php, and mysql needs to be installed.
You can also install the various parts yourself. Then configure it yourself.
Download address of each version of PHP: http://museum.php.net/php5/
Apche download address: http://prdownloads.sourceforge.net/appserv/appserv-win32-2.5.10.exe?download
MySQL download address: http://www.mysql.cn/
Configuration installation tutorial: http://wenku.baidu.com/view/c6118b1810a6f524ccbf85f9.html
Or https://www.jb51.net/article/33062.htm.
Writing tools: Notepad++ or dreamweaver cs4 is recommended
=
Syntax:
The syntax of PHP is simple-- look directly at the code: this is how PHP code is declared. Note: you can also write it in this way, but it is not recommended.
Mark the end of a statement: the semicolon marks the end of a statement ";"-the semicolon indicates the end of each statement.
=
Notes in PHP:-- see code in the tutorial for details
Comments in php have single-line comments: / / this is a comment
And large module comments: / * this is the comment * /
=
Variables:
The PHP variable is loose. But it is also case-sensitive, which we should pay attention to. There is no need to declare before using it-depending on how the variable is declared, PHP automatically converts the variable to the correct data type.
Declare variables in PHP using the $keyword-- all variables are identified by $
Variable naming rules:
Variable names must start with a letter or an underscore "_".
Variable names can only contain alphanumeric characters and underscores.
Variable names cannot contain spaces. If the variable name consists of multiple words, it should be separated by an underscore (such as $my_string) or start with an uppercase letter (such as $myString).
Note: (basically all programming languages have similar variable naming rules!)
Example:
The copy code is as follows:
Constant:
Declaration of constants in PHP:
Declaring constants in PHP is declared using the define function. Look directly at code.
The copy code is as follows:
There are also predefined constants in PHP-- you can consult the PHP manual or related materials.
=
Array:-- PHP's array is relatively simple and easy to use.
PHP arrays can be used as collections in other languages
Any type supported by PHP can be stored in the PHP array. Of course, you can also store class objects and so on-- just look at code.
The copy code is as follows:
=
PHP operator:-- excerpt from the tutorial on w3school
This section lists the various operators used in PHP:
Arithmetic operator
Operator illustrates the result of the example + Additionx=2
X+24-Subtractionx=2
5-x3*Multiplicationx=4
X*520/Division15/5
5/23
2.5%Modulus (division remainder) 5% 2
10% 8
10% 21
two
0++Incrementx=5
X++x=6--Decrementx=5
X--x=4
Assignment operator
Operator description example = x=yx=y+=x+=yx=x+y-=x-=yx=x-y*=x*=yx=x*y/=x/=yx=x/y.=x.=yx=x.y%=x%=yx=x%y
Comparison operator
Operator illustration example = = is equal to5==8 returns false examples is not equal5 examples 8 returns true > is greater than5 > 8 returns false=8 returns false
PHP loop:
Like other strongly typed programming languages. Php also has while, do while, for, foreach-- look directly at code
The copy code is as follows:
PHP function:
The declaration of the php function is simple, as long as the keyword function is preceded by the function name. -- look directly at code for specific format.
The copy code is as follows:
PHP class:
Like other high-level languages, php supports object-oriented programming. Here I'm talking about the declaration of the basic part of the php class. There is something about the way of object-oriented programming, which we study by ourselves.
The way php declares classes, also add the keyword class-- look at code specifically-- including static functions. Function calls, etc.)
The copy code is as follows:
PHP form processing:
When the page user submits the value, use $_ GET and $_ POST or $_ REQUEST (which contains $_ GET, $_ POST and $_ COOKIE) system-defined variables to read the submitted value-- see code
The copy code is as follows:
The above is all the content of this article "what are the basic grammars of PHP?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to 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.