Summary of various judgments on strings in php

不言
Release: 2023-04-03 16:02:02
Original
1939 people have browsed it

The content of this article is to share with you a summary of various judgments on strings in PHP. The content is very detailed and has certain reference value. I hope it can help friends in need.

1. Determine whether the string is empty

$namedRange !== NULL$pSheet === NULL
Copy after login

2. Determine whether the file exists and whether it is readable

(file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)
Copy after login

3. Compare the two "PHP normalized" version number strings

version_compare ( string $version1 , string $version2 [, string $operator ] )

Return mixed string $version1 – version 1 required string $version2 – version 2 required string $operator – understood as Optional operators

are <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <> and ne.

If the third parameter is specified, a boolean is returned. If the third parameter is not specified, the following three situations are returned:

The first version is lower than the second version. Return -1 when the first version is equal to the second version, return 0 when the first version is less than the second version, return 1**Example**version_compare(PHP_VERSION, '5.3.0') >= 0

Recommended related articles:

Parsing of AES encrypted files in PHP (with code)

Summary of methods for extracting numbers from strings in PHP (code )

The above is the detailed content of Summary of various judgments on strings in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template