Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example Analysis of PHP basic Grammar

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the example analysis of PHP basic grammar, which is very detailed and has certain reference value. Friends who are interested must finish it!

What is php

PHP, namely "PHP: Hypertext Preprocessor", is a widely used open source general scripting language, especially suitable for Web development and can be embedded in HTML. Its grammar makes use of C, Java and Perl, making it easy to learn. The main goal of the language is to allow web developers to quickly write dynamically generated web pages, but the purpose of PHP is much more than that.

Simply put, php is a scripting language that can do a lot of things. ① server-side script ② command line script ③ to write desktop programs

2. Start php

(1) download the php interpreter, in fact, under the win, the simplest software is wamp. You can download everything.

(2) it seems that you still need to install the link library mscvr110.dll and the vc2012 runtime library under win.

(3) ide, shamelessly used phpStorm. I will make it up to you when I have money, so....

User: newaspLicense:= LICENSE BEGIN = 14617-1204201000001xrVkhnPuMZWoGg "DprWxZCBwsy8T91O7MRuNVHtrbzv8O9mmoLvtijcHSSE7i5Jrbread = LICENSE END =

Third, getting started.

(1) simple output

/ / this is the simplest form submission and data reception.

Basic Grammar

(1) PHP marker

(2) separate from HTML

/ / anything other than the beginning and end of the pair will be ignored by the PHP interpreter. That is, a mixture of html tags and PHP code, just like jsp,asp.

This is going to be ignored by PHP and displayed by the browser.

This will also be ignored by PHP and displayed by the browser.

/ / conditions of use, advanced separation This will show if the expression is true. Otherwise this will show.

(3) instruction delimiter, comment

PHP needs to end the instruction with a delimiter after each statement.

Note: / / or / *. * / but, * / will match the nearest one, remember! Remember!

5. Types

PHP supports eight raw data types.

Four scalar types: boolean (Boolean), integer (integer), float (floating point, double), string (string)

Two compound types: array (array) and object (object)

Two special types: resource (resource) and NULL (no type)

(1) Boolean Boolean type

Can be TRUE or FALSE, case-insensitive.

Generally, it is not 0, that is, TRUE.

(2) Integer integer

Integers can be represented in decimal, hexadecimal, octal or binary. Octal must be preceded by 0 (zero), hexadecimal plus 0x, binary plus 0b.

If a given number is outside the range of interger, it will be interpreted as float. The same result is out of the integer range, and the same is true.

Php does not have an integer division operator, and 1 prime 2 will produce float 0.5. You can cast to integer or use round () for better rounding.

Echo (int) 2.9; / / output 2echo round (2.555, 2) / / output 2.56 2echo round / never force an unknown score to integer, which can sometimes lead to unpredictable results.

(3) Float floating point (double)

Floating-point, also known as floating-point float, double-precision double, real real.

(4) String character conversion

A string string consists of a series of characters, where each character is equivalent to a byte. This means that php can only support 256 character sets, so Unicode is not supported.

String can reach a maximum of 2GB.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report