副本;
35、使用error_reporting(0)函数来预防潜在的敏感信息显示给用户,理想的错误
报告应该被完全禁用在php.ini文件里。可是如果你在用一个共享的虚拟主机,php.ini你不能修改,那么你最好添加error_reporting(0)函数,放在每个脚本文件的第一行(或用require_once()来加载)这能有效的保护敏感的SQL查询和路径在出错时不被显示;
36、使用 gzcompress() 和gzuncompress() 对容量大的字符串进行压缩(解压)在存进(取出)数据库时。这种内置的函数使用gzip算法能
压缩到90%;
37、通过参数变量地址得引用来使一个函数有多个返回值。你可以在变量前加个“&;”来表示按地址传递而非按值传递;
38、Fully understand “magic quotes” and the dangers of SQL injection. I’m hoping that most developers reading this are already familiar with SQL injection.However, I list it here because it’s absolutely critical to understand. If you’ve never heard the term before, spend the entire rest of the day googling and reading.
39、使用strlen()因为要调用一些其他操作例如lowercase和hash表
查询所以速度不是太好,我们可以用isset()来实现相似的功能,isset()速度优于strlen();
40、When incrementing or decrementing the value of the variable $i++ happens to be a tad slower then ++$i. This is something
PHP specific and does not apply to other languages, so don’t go modifying your C or
Java code thinki
ng it’ll suddenly become faster, it won’t. ++$i happens to be faster in PHP because instead of 4 opcodes used for $i++ you only need 3. Post incrementation actually causes in the creation of a temporary var that is then incremented. While pre-incrementation increases the original value directly. This is one of the optimization that opcode optimized like Zend’s PHP optimizer. It is a still a good idea to keep in mind since not all opcode optimizers perform this optimization and there are plenty of ISPs and servers running without an opcode optimizer.