php - PHP用empty()或truthy检查变量
问题描述
谁能告诉我在 if 语句中使用 empty() 函数或“truthy”检查变量是否具有值之间的区别?据我所知,他们实现了同样的目标?.. 我正在为 Wordress 编写一个函数,该函数循环遍历分类法并且两者都可以工作,但我不确定哪个是最好的。
$taxonomies = get_taxonomies($args, $output, $operator);
if (!empty($taxonomies)) {
...code here
}
或者
$taxonomies = get_taxonomies($args, $output, $operator);
if ($taxonomies) {
...code here
}
解决方案
推荐阅读
- c - 如何在 dpdk 数据包中显示或执行 eDNS?
- flutter - Flutter 如何使用 WorkManager 插件发送 Http (post) 请求
- c# - 如何拆分数组以最小化两个数组之和相减的绝对值?
- xaml - 将转换器与 Label 的可见性 Xamarin 表单一起使用时如何将默认值设置为 false
- python - 当相同的键出现多次时将文本文件转换为字典
- node.js - Flutter HTTP 发布请求 JSON 处理无法正常工作
- bash - Bash 检查多个单词以匹配一个单词
- slack - 如何存储 Slack 消息中共享的每个链接?
- azure-devops - Azure DevOps 自托管代理
- .htaccess - 如何拒绝访问 .htaccess 中的目录