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.