1
| 例sublime, setting增加,"show_encoding" : true
|
1
2
3
| 例,sublime
"word_wrap": "true",
"wrap_width": 80,
|
1
2
| 例,sublime
"tab_size": 4,
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| 例,
a.php
class A
{
}
b.php
function demo()
{
}
c.php
define('A', value);
d.php
ini_set('some_vars', value);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| class StudlyCaps
{
}
trait StudlyCaps
{
}
Interface StudlyCaps
{
}
|
1
2
3
4
| define('FOO_BAR', 'something more');
const FOO_BAR = value;
|
1
2
3
4
5
6
7
8
| class StudlyCaps
{
public function studlyCaps()
{
// coding...
}
}
|
1
2
3
4
5
| function snake_case()
{
// coding...
}
|
1
2
3
4
5
6
7
8
| class StudlyCaps
{
private function _studlyCaps()
{
// coding...
}
}
|
1
2
3
4
5
6
7
8
| class StudlyCaps
{
public function doSomething()
{
// coding...
}
}
|
1
2
3
4
5
6
7
8
9
10
|
class StudlyCaps
{
public function doSomething()
{
$someVariable = 'demo';
// coding...
}
}
|
1
2
3
4
5
6
7
8
9
|
class StudlyCaps
{
public function doSomething($variableOne, $variableTwo)
{
// coding...
}
}
|
1
2
3
| $a = $b + $c;
$a = $b . $c;
|
1
2
3
4
| namespace Standard;
// 空一行
use Test\TestClass;//use引入类
// 空一行
|
1
2
3
4
| class StudlyCaps
{
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
| class StudlyCaps
{
public function studlyCaps()
{
// coding...
}
}
function snake_case()
{
// coding...
}
|
1
2
3
4
5
6
7
8
9
10
| abstract class StudlyCaps
{
abstract public function studlyCaps();
final public static function studlyCapsOne()
{
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| if ($valueOne === $valueTwo) {
// code...
}
switch ($valueThree) {
case 'value':
// code...
break;
default:
// code...
break;
}
do {
// code...
} while ($valueFour <= 10);
while ($valueFive <= 10) {
// code...
}
for ($i = 0; $i < $valueSix; $i++) {
// code...
}
$demo = new Demo()
$demo->doSomething();
do_something();
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| if ($valueOne === $valueTwo) {
// code...
}
switch ($valueThree) {
case 'value':
// code...
break;
default:
// code...
break;
}
do {
// code...
} while ($valueFour <= 10);
while ($valueFive <= 10) {
// code...
}
for ($i = 0; $i < $valueSix; $i++) {
// code...
}
|
1
2
3
| if ($valueOne === $valueTwo) {// 控制结构(右边和)左边不加空格
// code...
}
|
1
2
3
4
5
6
7
8
9
| // heredoc语法
$sql = <<<SQL
SELECT delivery_id
FROM d_test
WHERE delivery_id
IN (123,234)
GROUP BY delivery_id
HAVING SUM(send_number) <= 0;
SQL;
|
1
2
3
4
5
6
7
| if ($a > 0
&& $b > 0
&& $c > 0
&& $d > 0
&& $e > 0) {
}
|
1
2
3
4
5
6
7
8
9
10
| public function tooLangFunction(
$valueOne = '',
$valueTwo = '',
$valueThree = '',
$valueFour = '',
$valueFive = '',
$valueSix = '')
{
//coding...
}
|
1
2
3
| $this->nameTest->functionOne()
->functionTwo()
->functionThree();
|
1
2
3
4
| $a = [
'aaa' => 'aaa',
'bbb' => 'bbb'
];
|
1
2
| $str = 'str';
$arg = "$str";
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| /**
* 类描述
*
* desc
*/
class StandardExample
{
/**
* 常量描述.
*
* @var string
*/
const THIS_IS_A_CONST = '';
/**
* 属性描述.
*
* @var string
*/
public $nameTest = '';
/**
* 构造函数.
*
* 构造函数描述
* @author name <email>
* @param string $value 形参名称/描述
* @return 返回值类型 返回值描述
* 返回值类型:string,array,object,mixed(多种,不确定的),void(无返回值)
*/
public function __construct($value = '')
{
// coding...
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
| /**
* 成员方法名称.
*
* 成员方法描述
*
* @param string $value 形参名称/描述
*
* @example domain/api/controller/action?argu1=111&argu2=222
*/
public function testFunction($value = '')
{
// code...
}
|
1
2
3
4
5
6
7
8
| try {
// coding...
} catch (\Exception $e) {
// coding...
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| // 改写doSome为doSomething
class StandardExample
{
/**
* 方法列表
*
* @var array
*/
private $_functionList = [];
public function __construct($functionList = array())
{
$this->_functionList = $value;
}
public function doSome()
{
$this->functionOne();
$this->functionTwo();
$this->functionThree();
$this->functionFour();
}
public function doSomething()
{
foreach($this->_functionList as $function) {
$this->$function();
}
}
...
}
|
1
2
3
4
5
6
7
| // +----------------------------------------------------------------------
// | Company Name xx服务
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://domain All rights reserved.
// +----------------------------------------------------------------------
// | Author: name <email>
// +----------------------------------------------------------------------
|