[Php 4, Php 5, Php 7, Php 8]
Strval - Nhận giá trị chuỗi của một biến — Get string value of a variable
Sự mô tả
Strval [hỗn hợp $value
]: Chuỗi[mixed $value
]: string
Nhận giá trị chuỗi của một biến. Xem tài liệu về chuỗi để biết thêm thông tin về chuyển đổi thành chuỗi.string for more information on converting to string.
Hàm này không thực hiện định dạng trên giá trị trả về. Nếu bạn đang tìm kiếm một cách để định dạng một giá trị số dưới dạng chuỗi, vui lòng xem Sprintf [] hoặc Number_format [].sprintf[] or number_format[].
Thông số
value
Biến đang được chuyển đổi thành một chuỗi.string.
value
có thể là bất kỳ loại vô hướng hoặc một đối tượng thực hiện phương thức __tostring []. Bạn không thể sử dụng strval [] trên các mảng hoặc trên các đối tượng không thực hiện phương thức __toString [].strval[] on arrays or on objects that do not implement the
__toString[] method.
Trả về giá trị
Giá trị chuỗi của value
.string value of value
.
Ví dụ
Ví dụ #1 strval [] Ví dụ sử dụng phương thức php ma thuật __tostring [].strval[] example using PHP magic __toString[] method.
Xem thêm
- boolval [] - Nhận giá trị boolean của một biến
- floatVal [] - nhận giá trị float của một biến
- intval [] - Nhận giá trị số nguyên của một biến
- setType [] - Đặt loại biến
- Sprintf [] - Trả về chuỗi được định dạng
- number_format [] - Định dạng một số với hàng ngàn nhóm
- Loại tung hứng
- __toString[]
Hayley Watson ¶ ¶
15 năm trước
As of PHP 5.2, strval[] will return the string value of an object, calling its __toString[] method to determine what that value is.
Đánh dấu Clements ¶ ¶
6 năm trước
Some notes about how this function has changed over time, with regards the following statement:
> You cannot use strval[] on arrays or on objects that
> do not implement the __toString[] method.
== Arrays ==
In PHP 5.3 and below, strval[array[1, 2, 3]] would return the string "Array" without any sort of error occurring.
value
0
value
1
value
2
value
3
value
4Tom Nicholson ¶ ¶
18 năm trước
value
5
value
6
value
7
value
8
value
9
value
0
value
1Kendsyder+phpnet tại gmail dot com ¶ ¶
15 năm trước
value
2
value
3
value
4
value
4Đánh dấu Clements ¶ ¶
6 năm trước
value
6
value
7
value
8
value
9
value
4Tom Nicholson ¶ ¶
6 năm trước
value
1
value
2
value
4Tom Nicholson ¶ ¶
15 năm trước
value
4
value
5
value
6
value
7
value
4Đánh dấu Clements ¶ ¶
6 năm trước
value
9
0
1
2
3
4
5
6
7
value
4Tom Nicholson ¶ ¶
18 năm trước
9
As of PHP 5.2, strval[] will return the string value of an object, calling its __toString[] method to determine what that value is.
0
As of PHP 5.2, strval[] will return the string value of an object, calling its __toString[] method to determine what that value is.
1
As of PHP 5.2, strval[] will return the string value of an object, calling its __toString[] method to determine what that value is.
2
value
4