Похожие чаты

Hi How can I customize what will return when using (array)

new class_name?
I need to return an array in this way not whole class properties

3 ответов

9 просмотров

class yourClass { public function toArray() { return [...]; } }

The closest one is probably jsonserializable or try this https://stackoverflow.com/questions/11841637/php-arrayable-interface

Make an explicit named method and call it Stop relying or even using magic methods, it's bad, it hides details without proper interfaces, even confuses IDEs, let alone other fellow developers who will work on it in future

Похожие вопросы

Обсуждают сегодня

Карта сайта