API Implementation-Collection of common programming errors

Im trying to begin to work with a API to call a few bits of information

The documentation for it is quite scarse and the support is quite slim however it is quite good in its way

Ive recently started to learn bits about arrays etc however im not too sure if that would be my hurdle on this specific question

the one part of the API im struggling on is this:

// Get the character object. Will return FALSE if the
// character could not be found or character is frozen.
 $character = $armory->getCharacter('xxxx');

Now im quite stuck on how to find if its “FALSE”

This is an extract from the class file if its any help for you guys:

            function __construct($region, $realm, $character, $ignoreFields = FALSE) {
    if ($ignoreFields != FALSE){
        $this->excludeFields($ignoreFields);
    }
    $this->region = strtolower($region);
    $this->realm = $realm;
    $this->name = $character;
    $jsonConnect = new jsonConnect();
    $this->characterData = $jsonConnect->getCharacter($character, $realm, $region, implode(",",$this->fields));
    if ($this->characterData != FALSE){
        $this->name = $this->characterData['name'];
        $this->setTitles();
        $this->setTalentTreeSelected();
        $this->race = new Races($region);
        $this->class = new Classes($region);
    } else {
        return FALSE;
    }
    return TRUE;
}

https://sourceforge.net/p/wowarmoryapi/home/ is the API if any of you wish to see the full api or command list

thanks

  1. if ($character->isValid() === false) {
         //your code that runs if there is no character
    }
    else {
         //your code that runs if everything is fine
    }
    
  2. if ($character) {
      // true stuff 
    } else {
      // false stuff
    }
    

    Many things evaluate to logical “false” in php: Numeric value 0, Empty string, Undefined/uninitialized variable Empty array etc. etc.

Originally posted 2013-11-09 20:29:42.