This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 判断数字类型 | |
| is_numeric() | |
| is_int() is_integer() is_long() | |
| is_float() is_real() is_double() | |
| // 求绝对值 | |
| abs() | |
| // 进一,去整,四舍五入 | |
| float round ( float $val [, int $precision = 0 [, int $mode = PHP_ROUND_HALF_UP ]] ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 让索引数组从0开始 | |
| $presidents = array(1 => 'Washington', 'Adams', 'Jefferson', 'Madison'); | |
| // 使用 while list each 遍历数组 | |
| while(list($key, $value) = each ($arrays)) { | |
| // | |
| } | |
| // 删除数组元素 | |
| unset() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // You don't want to accidentally assign values when comparing a variable to a constant. | |
| Use: | |
| if (12 == $a) {} | |
| instead of: | |
| if ($a == 12) {} | |
| // You want to assign a default value to a variable that doesn't already have a value. | |
| $cars = isset($_GET['cars']) ? $_GET['cars'] : $default_cars; | |
| $cars = array_key_exists('cars', $_GET) ? $_GET['cars'] : $default_cars; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected function see($text, $element= 'body') | |
| { | |
| $crawler = $this->client->getCrawler(); | |
| $found = $crawler->filter("{$element}:contains('{$text}')"); | |
| $this->assertGreaterThan(0, count($found), "Excepted to see {$text} with view"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function setUp() | |
| { | |
| parent::setUp(); | |
| $this->task = Mockery::mock('Acme\TaskReponsitoryInterface'); | |
| App::instance('Acme\TaskReponsitoryInterface', $this->task); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var human = { | |
| species: "human", | |
| create: function(values) { | |
| var instance = Object.create(this); | |
| Object.keys(values).forEach(function(key) { | |
| instance[key] = values[key]; | |
| }); | |
| return instance; | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 自定义时间 | |
| jQuery.fx.speeds = { | |
| slow: 600, | |
| fast: 200, | |
| // Default speed | |
| _default: 400 | |
| }; | |
| // 修改时间 | |
| $.fx.speeds._default = 500; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <body> | |
| <script id="blogTemplate" type="app/template"> | |
| <h2> {{title}} </h2> | |
| <img src="{{thumbnail}}" alt="{{title}}"/> | |
| </script> | |
| <script> | |
| (function($) { | |
| var content = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .cf:before, | |
| .cf:after { | |
| content: ' '; | |
| display: table; | |
| } | |
| .cf:after { | |
| clear: both; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function makeTree($arr) { | |
| $result = ''; | |
| foreach ($arr as $key => $value) { | |
| $result .= '<li>' . (is_array($value) ? ($key . makeTree($value)) : $value) . '</li>'; | |
| } |