我试图开始使用API来调用一些信息
它的文档很简陋,支持很细,但它的方式非常好
我最近开始学习关于阵列等的内容,但是我不太确定这是否是我在这个特定问题上的障碍
我正在努力的API的一部分就是:
// Get the character object. Will return FALSE if the
// character could not be found or character is frozen.
$character = $armory->getCharacter('xxxx');
现在我非常坚持如何找到它的“FALSE”
如果对你们有任何帮助,这是类文件的摘录:
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/是API,如果您有任何人希望查看完整的api或命令列表
感谢
答案 0 :(得分:0)
if ($character->isValid() === false) {
//your code that runs if there is no character
}
else {
//your code that runs if everything is fine
}
答案 1 :(得分:0)
if ($character) {
// true stuff
} else {
// false stuff
}
很多东西在php中评估为逻辑“false”: 数值0, 空字符串, 未定义/未初始化的变量 空数组等等。