ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
[TOC] ### 静态化属性 因为静态化后,执行过程中只初始化一次 ``` function send_http_status($code) { static $_status = array( // Informational 1xx 100 => 'Continue', 101 => 'Switching Protocols', // Success 2xx 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', ... ... ); } ``` ### 递增一个未预定义的局部变量要比递增一个预定义的局部变量慢9至10倍 ### 检测字符串长度 ``` if (strlen($foo) < 5) { echo "Foo is too short"; } if (!isset($foo{5})) { echo "Foo is too short"; } //更优 ```