Hướng dẫn
Quảng cáo

Hàm strlen() trong PHP

Hướng dẫn cách sử dụng hàm strlen() trong lập trình PHP

Tác dụng của hàm strlen()

The strlen() function returns the length of a string.

The following table summarizes the technical details of this function.

Return Value: Returns the length of the string on success, and 0 if the string is empty.
Version: PHP 4+

Syntax

The basic syntax of the strlen() function is given with:

strlen(string);

The following example shows the strlen() function in action.

<?php
// Sample string
$str = "Hello World!";

// Getting the string length
echo strlen($str);
?>

Parameters

The strlen() function accepts the following parameters.

Parameter Description
string Required. Specifies the string to check for length.

Bài viết này đã giúp ích cho bạn?

Bài viết mới

Advertisements