- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我应该在实时服务器上启用 E_NOTICE 吗?
正如我在 Why should I fix E_NOTICE errors? 中看到的那样
每个人都再次使用 isset()
省略通知。我读过专业人士,但代码可读性如何?
让我们检查一些代码:
if ($this->_oldattributes['category_id'] != $tattr['category_id']
|| $this->_oldattributes['deal_id'] != $tattr['deal_id']
) {
isset()
省略通知:
$old_cat_id = isset($this->_oldattributes['category_id']) ? $this->_oldattributes['category_id'] : null;
$new_cat_id = isset($tattr['category_id']) ? $tattr['category_id'] : null;
$old_deal_id = isset($this->_oldattributes['deal_id']) ? $this->_oldattributes['deal_id'] : null;
$new_deal_id = isset($tattr['deal_id']) ? $tattr['deal_id'] : null;
if ($old_cat_id != $new_cat_id || $old_deal_id != $new_deal_id) {
The difference was that suppressing the notice took 100% as long as just checking if it existed first" Test was performed on 1000000 supressions. How many of them appears in your code, even if you use Zend+Doctrine+something else? And how many time does it takes in comparison to DB connections, etc.?
class Item extends CActiveRecord {
private $_oldattributes = array();
public function afterFind()
{
// Save old values
$this->_oldattributes = $this->getAttributes();
$this->_oldcategory = $this->category;
$this->_olddeal = $this->deal;
}
$tattr = $this->getAttributes();
$this->_oldattributes['category_id'] != $tattr['category_id']
$this->deal->item->id != $this->_olddeal->item->id
if ($_GET['foo']) ...
if (isset($_GET['foo']) && $_GET['foo']) ...
if (@$_GET['foo']) ...
最佳答案
例如,当我查看您的代码时
$this->_oldattributes['category_id']
class Attributes {
public $categoryId;
// and so on
}
isset()
不再,因为现在该属性存在(可能是
null
)或者它绝对是一个错误(“未定义的属性”)并且应该修复。我认为您的大多数情况都是用
isset()
“修复”的。 , 属于这种。
关于php - 为什么要修复 E_NOTICE 错误?优点和缺点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10077164/
下面我有一段代码可以在我的大多数简单程序中运行.. . 我想知道它是好是坏……以及利弊。 . win32头文件:win32.h // example of a not realated code to
了解到我们可以使用双括号初始化在 java 中初始化集合。并对其进行了一些搜索,发现由于其性能问题,不建议使用它。 private static final Set VALID_CODES = new
在 Java 中使枚举类似于类,而不是像 C/C++ 中的常量集合,有哪些优点? 最佳答案 您可以免费在编译时检查有效值。使用 public static int OPTION_ONE = 0; pu
我目前正在研究ruleML,我想知道是否有人可以给我列出一些优缺点? 谢谢 最佳答案 RuleML是语义网现有本体语言和查询系统的概括,例如OWL-DL,围绕RDF的工具集以及基于一阶逻辑的类似于Pr
每次我写某种形式的东西 let scorePopulation f population = Array.map (fun i -> f i) population 我最后问自己,我是否会写得更好
我总是从SQL专家那里听到,在SELECT语句中使用'*'符号效率不高,最好列出所有字段名称。 但是,对于将新字段添加到表然后相应地更新所有存储过程的情况下,我个人觉得效率不高。 那么使用'*'的优缺
我想知道通过将业务逻辑和数据与 Web 表单分离来分层 Web 应用程序的长期优势(如果有)。 (即表单、业务逻辑、数据不在同一个文件中,但每个都在另一个文件夹中的自己的类中,或者与其他类似的类组合)
我目前正在从事一个项目,其中分支和合并从一开始就运行得不太好。为了改变这一点,我们一直在讨论多种不同的方法。我想每个人对于如何做这类事情都有自己的哲学,所以它似乎也在这里。 我们一直在讨论的一件事是按
是 StyleCop好用,有什么优缺点? 我还下载了 StyleCop,Resharper StyleCop。 我正在使用 resharper,它有自己的编码标准,而 StyleCop 也有自己的,我
我刚刚开始学习C#,并使用Tutorials Point来完成此操作。在数组部分,我一直看到声明为 string[] sarray = { "Hello", "From", "Tutorials",
使 Java 中的枚举类似于类,而不是像 C/C++ 中那样只是常量的集合有哪些优势? 最佳答案 您可以获得有效值的免费编译时检查。使用 public static int OPTION_ONE =
您会在什么情况下使用 volatile 关键字?更重要的是:该计划如何从中受益? 根据我已经阅读和了解的内容:volatile 应该用于被不同线程访问的变量,因为它们比非 volatile 变量读取起
至少有三种众所周知的创建并发应用程序的方法: 通过锁定(.NET、Java)实现多线程和内存同步。软件事务内存 (link text) 是另一种同步方法。 异步消息传递(Erlang)。 我想了解是否
在对JCR or RDBMS进行了一些研究并阅读了其他posts之后,我仍然不确定是否将JCR over JPA用于文档管理系统,该系统必须处理不同的文档类型,非常大的文件和并发访问很多来自许多用户。
X 来自 http://drupal.org/node/953016 的帖子 Drupal 7 AJAX 系统很棒,它对表单甚至链接都非常流畅。 我无法以理智的方式解决方法是从 javascript
我的 .htaccess 中有一堆规则(子域、文件夹、用户特定的文件夹等...) 我现在正在使用这个正则表达式: ([a-z0-9A-Z]) 我正在寻找一个特定的规则,我找到了多种构建它的方法,我想知
好吧,我想这很清楚我试图对此进行推理的方向。 这些天有很多关于不变性(constness)的优点的讨论。 Java 中的并发编程一书也对此进行了很多讨论。 然而,这一切只是我所读到的。我个人没有用函数
我正在开发一个 Android 应用程序,但我遇到了一个无法以某种方式做出决定的决定。我希望有人能够阐明常见的做法以及支持它们的任何理论。 问题是这样的: 我想要一个包含图像和文本(例如表格)的项目列
是否可以使用 ≠ 而不是 !=。我知道这是一个额外的 alt 代码,我从未在项目中使用过它,但我已经对其进行了测试并且可以正常工作。除了必须 Alt +8800 之外还有什么优点/缺点吗? 编辑:我不
Visual Studio (sqlmetal) 生成的 dbml 文件带有映射到数据库表的实体。在您看来,这些类适合用作领域模型类吗?还是应该避免它们,只将它们隔离到数据访问层? 谢谢 最佳答案 在
我是一名优秀的程序员,十分优秀!