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

    Reactie:

    Annuleren

  • Rubrieken

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

    • A trim() method for the JavaScript String class
    • Is u iets opgevallen?
    • Tip: use the axis:axis:1.4 Maven artifact if you need Axis 1.4 support
    • Google Closure tools
    • Google en Microsoft indexeren tweets
  • Gerelateerde berichten

    • Simple Cloud API
    • Showing related articles in a WordPress blog
    • PHP tip: omit ?> from PHP only files
    • MySQL STRICT_TRANS_TABLES mode and truncated text values
    • Archives for a category WordPress plugin
  • Abonneren

    • Atom feed Artikelen
    • Atom feed Reacties
  • Archief

© Rob Schlüter - Contact