You are viewing a single comment's thread from:

RE: PHP: Use associative arrays basically never

in #php3 years ago (edited)

Hi there:

I really tried to use model classes but it is impractical.

Let's say we want to json_serialize. Ok, it is not a problem. But what if we have a field that it's composed by another model

class Customer {
      var $fieldId=1;
      var $name="";
      var $typeCustomer=new TypeCustomer(); // or we could initialize in the constructor.
}

Serializing it's not fun. However, de-serializing (json) is a big challenge because the system doesn't understand the field $typeCustomer if an object and it de-serialize as stdClass, then every method attached to TypeCustomer fails.

https://dev.to/jorgecc/php-is-bad-for-object-oriented-programming-oop-282a