PHP hỗ trợ các hàm
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
9 và Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
0 được sử dụng để chuyển đổi các đối tượng lớp, mảng và dữ liệu vô hướng khác sang dạng chuỗi được tuần tự hóa và tạo lại chúng từ chuỗi được tuần tự hóaCác lớp PHP có thể cung cấp các triển khai tuần tự hóa của riêng chúng. Ví dụ: một lớp có thể loại trừ dữ liệu nhạy cảm nhất định khỏi việc thêm vào chuỗi được tuần tự hóa hoặc một lớp có thể thiết lập lại kết nối đến máy chủ từ xa từ URL máy chủ được lấy từ văn bản được tuần tự hóa
Có ba cách tiếp cận để cung cấp logic tuần tự hóa tùy chỉnh cho các lớp PHP
- Phương pháp ma thuật
1 vàDeprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
2Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
- Giao diện
3 và các phương thứcDeprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
4 vàDeprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
0 [kể từ PHP 5. 1]Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
- Phương pháp ma thuật
1 vàDeprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
2 [kể từ PHP 7. 4]Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
Triển khai các phương pháp
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
1 và Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
2 là cách được khuyến nghị, vì nó tránh được một số cạm bẫy với cách tiếp cận Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
1/Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
2 và giao diện Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
3Trong PHP8. 1, việc triển khai giao diện
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
3 mà không triển khai các phương thức Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
1 và Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
2 không được chấp nhậnclass Test implements Serializable{
public function serialize[] {}
public function unserialize[$data] {}
}
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
- Giao diện
1 không bị ảnh hưởngclass Test implements Serializable{ public function __serialize[]: array {} public function __unserialize[array $data]: void {} public function serialize[]: array {} public function unserialize[string $data]: void {} }
- Kể từ PHP 8. 0, Chữ ký phương pháp ma thuật lớp được thực thi nghiêm ngặt
Trở lại năm 2019, người ta đã đề xuất thêm hai phương pháp ma thuật mới là
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
1 và Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
2 vì cả hai phương pháp tiếp cận giao diện Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
2 + Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
1 và Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
3 đều không lý tưởng do tính phức tạp khi triển khai và hành vi có lỗi của chúngSự phản đối này trong PHP 8. 1 là phần tiếp theo của thay đổi đó, để ngừng triển khai giao diện
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
3 mà không có các phương thức ma thuật mới và cuối cùng là xóa giao diện Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
3 trong PHP 9. 0Nếu một lớp triển khai cả phương thức giao diện
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
3 và phương thức ma thuật, thì phương thức ma thuật sẽ được ưu tiên và thông báo không dùng nữa sẽ không được phát raTrong PHP7. 4 trở lên, các phương thức
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
1 và Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
2 được thực thi trong các cuộc gọi Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
32/Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
0, không phải các phương thức Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
9/Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
0 từ giao diện Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
3. Sẽ không có thông báo phản đối trong PHP 8. 1 hoặcclass Test implements Serializable{
public function __serialize[]: array {}
public function __unserialize[array $data]: void {}
public function serialize[]: array {}
public function unserialize[string $data]: void {}
}
Thay đổi liên quan
- PHP8. 1.
37 không được dùng nữaDeprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
Tác động tương thích ngược
Lưu ý rằng thông báo phản đối không được phát ra nếu lớp cũng thực hiện các phương thức
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
1 và Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
2Nếu một lớp triển khai cả phương thức giao diện
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
3 và phương thức ma thuật, thì phương thức ma thuật sẽ được ưu tiênTrên các ứng dụng có PHP 7. 4 là phiên bản tối thiểu, có thể bỏ triển khai giao diện
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
3 và triển khai các phương thức Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
1 và Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
2 mới một cách an toànTrên các ứng dụng phải hỗ trợ các phiên bản PHP cũ hơn PHP 7. 4, triển khai cả giao diện
Deprecated: Test implements the Serializable interface, which is deprecated. Implement __serialize[] and __unserialize[] instead [or in addition, if support for old PHP versions is necessary] in .. on line ...
3 [sẽ được sử dụng trên PHP