Home Backend Development PHP Tutorial Study Notes on PHP Data Types_PHP Tutorial

Study Notes on PHP Data Types_PHP Tutorial

Jul 13, 2016 am 10:50 AM
php string exist string study data have of notes type

There are 8 scalar types in PHP, including string (string), integer (integer), float (floating point type, also called double), boolean (Boolean type) and composite types and resources (resources) ), NULL (empty), let’s take a look below.

php data type
PHP supports eight primitive types (type).

4 scalar types:
string (string), integer (integer), float (floating point type, also called double), boolean (Boolean type)
Two compound types:
array(array), object(object)
Two special types:
resource(resource), NULL(empty)

Boolean
Syntax: To specify a Boolean value, use the keywords TRUE or FALSE. Both are case-insensitive.

When converted to boolean, the following values ​​are considered FALSE:
1> Boolean value FALSE
2> Integer value 0 (zero)
3> Floating point value 0.0 (zero)
4> Blank string and string “0″
5> Array without member variables
6> Object without unit
7> Special type NULL (including variables that have not been set)

All other values ​​are considered TRUE (including any resources).

Note: -1, like other non-zero values ​​(whether positive or negative), is considered TRUE!

================================================== ==================================
Shape(integer)
Syntax: Integer values ​​can be specified in decimal, hexadecimal or octal notation, preceded by an optional sign (- or +).
If you use octal notation, you must add 0 (zero) before the number, and if you use hexadecimal notation, you must add 0x before the number.

================================================== ===================================
string(string)

Three ways to define: single quotes, double quotes, delimiters.
String conversion:
You can convert a value to a string using the (string) notation or the strval() function.
The Boolean value TRUE will be converted to the string "1", while the value FALSE will be represented as "" (i.e. the empty string).
NULL will be converted to an empty string.

Convert string to numeric value
When a string is evaluated as a number, the following rules determine the type and value of the result.
If it contains any of the ".", "e" or "E" characters, the string is evaluated as a float. Otherwise it is treated as an integer. As shown below:

================================================== ====================================== array
The code is as follows
 代码如下 复制代码
$foo = 1 + “10.5″; // $foo is float (11.5)
$foo = 1 + “-1.3e3″; // $foo is float (-1299)
$foo = 1 + “bob-1.3e3″; // $foo is integer (1)
$foo = 1 + “bob3″; // $foo is integer (1)
$foo = 1 + “10 Small Pigs”; // $foo is integer (11)
$foo = 4 + “10.2 Little Piggies”; // $foo is float (14.2)
$foo = “10.0 pigs ” + 1; // $foo is float (11)
$foo = “10.0 pigs ” + 1.0; // $foo is float (11)
?>
Copy code


$foo = 1 + “10.5″; // $foo is float (11.5)

$foo = 1 + “-1.3e3″; // $foo is float (-1299)

$foo = 1 + “bob-1.3e3″; // $foo is integer (1)
$foo = 1 + “bob3″; // $foo is integer (1)
$foo = 1 + “10 Small Pigs”; // $foo is integer (11)
$foo = 4 + “10.2 Little Piggies”; // $foo is float (14.2)
$foo = “10.0 pigs ” + 1; // $foo is float (11)
$foo = “10.0 pigs ” + 1.0; // $foo is float (11)
?>


An array in PHP is actually an ordered graph. A graph is a type that maps values ​​to keys. Utility functions: The unset() function allows unsetting a key in an array. Be aware that the array will not be reindexed. ================================================== ================================= NULL The special NULL value indicates that a variable has no value. The only possible value of type NULL is NULL. Note: The NULL type was introduced in PHP 4. A variable is considered NULL in the following situations: is assigned the value NULL. has not been assigned a value yet. is unset().

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632623.htmlTechArticleThere are 8 scalar types in php, including string (string), integer (integer), float (floating point type, also called double), boolean (Boolean) and composite types and resource (resource), NULL (empty), next...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

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

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

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

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

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

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

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

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

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 Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

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

See all articles