技巧性代码

1. 函数调用
function run_urlencode($input, $urlencode = false) { if ($urlencode) { return $this->{$urlencode}($input); } elseif ($this->urlencode) { return $this->{$this->urlencode}($input); } else { return $input; } }

2.递归调用
public function curl_init() { if ($this->ch !== null) { throw new \S\Exception('curl init already'); } $this->ch = curl_init(); $this->curl_id = $this->get_curl_id($this->ch); $this->curl_cli = 'curl -v '; $this->curl_setopt(); }

3.array_map()取代foreach
public function decorate() { //something to do }

$slave = array( 'JK Dr', 'King L' );
array_map('decorate', $slave);

4.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,477评论 19 139
  • 背景 一年多以前我在知乎上答了有关LeetCode的问题, 分享了一些自己做题目的经验。 张土汪:刷leetcod...
    土汪阅读 14,351评论 0 33
  • 转载自:http://www.cnblogs.com/txw1958/archive/2013/01/19/286...
    php_bruce阅读 6,820评论 1 5
  • RxBus : 通过RxJava实现Rxbus。 目前大多数开发者使用EventBus或者Otto作为事件总线通信...
    sirai阅读 7,773评论 2 9
  • (如果,时间可以停留,我希望停在遇到你的现在。世界那么大,能够遇到你不容易) 喜欢畅想在唯美的世界中,那种感觉妙不...
    迷雾纠纷阅读 3,051评论 4 3