Kwebble : blog

  • Don’t forget __isset() with overloaded setters and getters

    Gepubliceerd op 21 augustus 2008 in Programming.

    This post is mostly a marker for me to find the solution for this problem in the future. What problem? Well, a call using empty() to test a class field always returned true even if the field wasn’t empty.

    The reason for this behavior is that the class overloads __set() and __get() to do some extra checking on the fields. But overloading these functions also effects empty(). To make empty() behave normally __isset() must also be overloaded to test the used fields.

    And when implementing __isset() think about __unset(), maybe you need to overload it as well.

    The PHP Manual contains an example of overloading these magic members.

    • oop
    • php

    Laat een reactie achter

  • Rubrieken

    • Artikelen
    • Foto's
    • Links
    • Overheid
    • Programming
  • Recente Berichten

    • Federal IT Dashboard
    • NoSQL
    • Smiley guppy
    • Kwebble 4.0
    • Rotterdams havenbedrijf laat natuur aanleggen?
  • Abonneren

    • Atom feed Artikelen
    • Atom feed Reacties
  • Archief

© Rob Schlüter - Contact