|
update : 2015.11.03
php.shukuma.com검색:
|
JsonSerializable::jsonSerialize(PHP 5 >= 5.4.0, PHP 7) JsonSerializable::jsonSerialize — Specify data which should be serialized to JSON 설명Serializes the object to a value that can be serialized natively by json_encode(). 인수이 함수는 인수가 없습니다. 반환값Returns data which can be serialized by json_encode(), which is a value of any type other than a resource. 예제
Example #1 JsonSerializable::jsonSerialize() example returning an array
<?php위 예제의 출력:
[
1,
2,
3
]
Example #2 JsonSerializable::jsonSerialize() example returning an associative array
<?php위 예제의 출력:
{
"foo": "bar",
"quux": "baz"
}
Example #3 JsonSerializable::jsonSerialize() example returning an integer
<?php위 예제의 출력: 1 Example #4 JsonSerializable::jsonSerialize() example returning a string
<?php위 예제의 출력: "Hello!" |