PHP IN_ARRAY 函数使用注意事项_PHP
另外,我们在 控制结构比较两个数值是否一直的时候,也应该尽量使用 === 来代替 ==(当然,这个也根据具体的业务逻辑选用比较合适的)。
小弟来解释下 为什么
var_dump(in_array(0, array('s' ));
这句话的结果是bool(true)。
因为in_array会将0 和's' 进行比较,0是number类型,'s'是string类型,根据php manual 中“Comparison Operators” 一章的说明可知,number 和string进行
比较的时候,会先将string类型首先转化为number,然后再进行比较操作。 's'转化为number的结果为0,而0 == 0 的结果是true,所以in_array(0, array('s', 'ss'))的结果也是true
如果把in_array 的第三个参数strict设置为 true,比较的时候 就会判断值和类型是否都相当。如果都相当的话,才会返回true,否则返回false.
仅此为记。

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

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

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.

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

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

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

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