PHP learning officially sets sail (2)
Data type
PHP supports integers, floating point numbers, strings, arrays and objects. The variable type is usually not determined by the programmer but by the PHP running process. You can use cast or the function settype() to convert a certain type of variable into a specified type.
The numerical value type can be an integer or a float. Points. You can use the following statements to assign a value:
$a = 1234; # You need to understand decimal numbers
$a = -123; # You need to understand negative numbers
$a = 0123; # Octal numbers ( Equal to 83 in decimal)
$a = 0x12; # Hexadecimal number (equal to 18 in decimal)
$a = 1.234; # Floating point number "double precision number" to understand
$a = 1.2e3; # Exponential form of double precision number
Just know the integers and decimals here. . . .
String
Strings can be defined by fields enclosed in single quotes or double quotes. Note that the difference is that strings enclosed in single quotes are defined literally, while strings enclosed in double quotes can be expanded. Furthermore, you can use backslash\ in a double-quoted string to add escape sequences and conversion characters to the string. Examples are as follows:
$first = 'Hello'; $second = "World"; $full1 = "$first $second"; # 产生 Hello World $full2 = '$first $second';# 产生 $first $second
is used to concatenate two strings. Instead of +, please note that
$string=$first.$second; The result is HelloWorld
Operator PHP has commonly seen operators in C, C++ and Java. The precedence of these operators is also consistent. Assignment also uses "=". Arithmetic and Characters Only one of the following operators is related to characters:
$a + $b: Add
$a - $b: Subtract
$a * $b: Multiply
$a / $b: Divide
$a % $b: Modulo (remainder)
$a. $b: String connection logic and comparison logic operators are:
$a || $b: or
$a or $b: or
$a && $b: AND
$a and $b: AND
$a xor $b: XOR (when $a or $b is true is true, if both are the same, it is false)
! $a: Not
Comparison operators are:
$a == $b: Equal
$a != $b: Not equal
$a < $b: less than
$a <= $b: less than or equal to
$a > $b: greater than
$a >= $b: greater than or equal to
Like C, PHP also has the triple operator (?:). Bit operators also exist in PHP.
It’s really simple. .
Control process structure
PHP has the same process control as C.
if (expression two)
. . .
}
elseif (expression two)
{
. . .
}
else
{
. . .
}
switch is the best replacement for multiple if-elseif-else structures:
switch ($i) { case 0: print "i equals 0"; case 1: print "i equals 1"; case 2: print "i equals 2"; }
Loop structure
while (expression Formula)
{
. . .
}
do
{
. . .
}
while (expression );
for (expression one; expression two; expression three)
{
. . .
}
Also When using a loop foreach, say
break, continue
break to interrupt the current loop control structure.
continue is used to jump out of the remaining current loop and continue executing the next loop.
These are very simple, the same as C language, so we can forget them in a nutshell. . .

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.
