Does php have its own methods?

藏色散人
Release: 2023-03-17 06:00:01
Original
1304 people have browsed it

php has its own methods, the commonly used methods are: 1. strlen method, used to obtain the string length and byte length; 2. substr method, used to intercept strings; 3. strtolower method, Used to change all characters to lowercase; 4. strrev method, used to reverse a string; 5. time method, used to get the timestamp of the current time; 6. explode method, used to convert a string according to A specified rule divides the array into segments, and so on.

Does php have its own methods?

The operating environment of this tutorial: windows7 system, PHP version 8.1, DELL G3 computer

Does php come with its own method?

PHP has its own methods.

PHP’s methods are becoming more and more powerful, and it has a very rich set of built-in functions. The following is the commonly used PHP system function methods compiled by the editor for everyone. Welcome to refer to~

String function

strlen: Get the string length, byte length

substr: String interception, get the string (intercept according to bytes)

strchr: similar to substr, intercept from the specified position until the end

strrchr (get the file suffix name): the same as strchr , just look for characters starting from the right

strtolower: All characters are lowercase (for English letters)

strtoupper: All characters are uppercase

strrev: String reverse (Only English can be reversed: English storage has only one byte), reverse by byte

strpos: Find the position where the corresponding character appears in the string (numeric subscript), starting from the leftmost

strrpos: Same as strpos, just start looking from the right side of the string

trim: remove characters on both sides of the function, the default is spaces

Time and date function

time: Get the timestamp of the current time (integer: from 1970 Greenwich Time)

explode: *, convert a string into an array according to a specified rule (usually special characters) Divide into multiple segments, each segment is treated as an element of an array, and an index array is returned.

implode: Glue, combine all the elements in an array according to a specified rule (special characters) The elements are spliced into a string

array_merge: Merge refers to accumulating the elements in the two arrays. If the latter array has the same subscript (key name: association) as the previous array, then The value of the subsequent element will overwrite the previous one; if it is the same subscript of the index, the subscript will be automatically modified and superimposed into the previous array.

Data structure simulation function

array_shift: from * Remove elements from the front of the array, and get the value of the element

array_pop: * Remove the element from the back of the array, and get the value of the element

array_unshift: Push elements in from the front of the array, and get the current array Number of elements

array_push: Push elements from the back of the array to get the number of current array elements

Judge the variable

is_bool: Judge whether it is a Boolean type

is_float: Determine floating point type

is_integer: Determine integer type

is_object: Determine object

is_array: Determine array

is_string: Determine String

is_resource: Judgment resource

is_scalar: scalar is scalar, and the judgment is basic data types: integer, floating point, Boolean and string

is_null: Whether it is empty

is_numeric: Determine numbers or strings composed of pure numbers

gettype: get the data type

settype: change the data type

File* function

opendir(path): open a path resource (read all the data inside the path into memory)

readdir(path resource): read from the folder resource The name of the file pointed to by the current resource pointer. The pointer will move downward one bit

closedir (resource): release the corresponding file resource

scandir (path): read the internal content of a path All file names, returns an array, each element of the array is a file name.

file_exists: Determine whether a file exists (file is a broad sense: path and file)

is_dir: Determine whether a specified path exists (folder)

is_file: Determine a Specify whether the path is a file (file)

mkdir: Create a path, if the path exists, an error will be reported

rmdir: Remove the folder

file_get_contents: From a specified Read the data content in the file.

file_put_contents: Write the specified string to the corresponding file

fopen: Open a file resource

fgetc: c represents character, read one character at a time

fgets: s represents string, which means multiple characters can be read, depending on the specified read length or whether a newline is encountered (only one line of data can be read at most)

Both functions are * Operate on the current resource pointer. After reading, the pointer will be moved down.

fread: Get the specified length of data until the end of the file.

fwrite: Write data to the location of the file resource pointer. , writing things will not move the existing things back at the current location, but will overwrite them

fseek: Specify the pointer to the corresponding location

fclose: Use the corresponding file resource

copy: copy

unlink: delete file

rename: rename file

filemtime: m represents modify, the time when the file was last modified

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of Does php have its own methods?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!