PHP 开发工具推荐

今天小编给大家整理了一些php开发中可能需要用到的工具或组建,需要的朋友可以参考和收藏哦~

PHP 函数的 JavaScript 实现

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
module.exports = function array_sum (array) { // eslint-disable-line camelcase
   //  discuss at: http://locutus.io/php/array_sum/
   // original by: Kevin van Zonneveld (http://kvz.io)
   // bugfixed by: Nate
   // bugfixed by: Gilbert
   // improved by: David Pilia (http://www.beteck.it/)
   // improved by: Brett Zamir (http://brett-zamir.me)
   //   example 1: array_sum([4, 9, 182.6])
   //   returns 1: 195.6
   //   example 2: var $total = []
   //   example 2: var $index = 0.1
   //   example 2: for (var $y = 0; $y < 12; $y++){ $total[$y] = $y + $index }
   //   example 2: array_sum($total)
   //   returns 2: 67.2
   var key
   var sum = 0
   // input sanitation
   if ( typeof array !== 'object' ) {
     return null
   }
   for (key in array) {
     if (! isNaN ( parseFloat (array[key]))) {
       sum += parseFloat (array[key])
     }
   }
   return sum
}

点击查看>

Underscore.js 的 PHP 版

1
2
3
4
5
function __($item= null ) {
   $__ = new __;
   if (func_num_args() > 0 ) $__->_wrapped = $item;
   return $__;
}

点击查看>

自动生成 gitignore 文件

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
https: //www.gitignore.io/api/laravel
# Created by https: //www.gitignore.io/api/laravel
 
### Laravel ###
vendor/
node_modules/
npm-debug.log
 
# Laravel 4 specific
bootstrap/compiled.php
app/storage/
 
# Laravel 5 & Lumen specific
public /storage
public /hot
storage/*.key
.env.*.php
.env.php
.env
Homestead.yaml
Homestead.json
 
# Rocketeer PHP task runner and deployment package . https: //github.com/rocketeers/rocketeer
.rocketeer/
 
# End of https: //www.gitignore.io/api/laravel

点击查看>

爬虫组件

1
2
3
4
5
composer global require slince/spider *@dev
use Slince\Spider\Spider;
 
$spider = new Spider();
$spider->run( 'http://www.baidu.com' );

点击查看>

简单、 灵活、强大的 PHP 采集工具

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use QL\QueryList;
//采集某页面所有的图片
$data = QueryList::Query( 'http://cms.querylist.cc/bizhi/453.html' ,array(
     //采集规则库
     //'规则名' => array('jQuery选择器','要采集的属性'),
     'image' => array( 'img' , 'src' )
     ))->data;
//打印结果
print_r($data);
 
//采集某页面所有的超链接
//可以先手动获取要采集的页面源码
$html = file_get_contents( 'http://cms.querylist.cc/google/list_1.html' );
//然后可以把页面源码或者HTML片段传给QueryList
$data = QueryList::Query($html,array(
     'link' => array( 'a' , 'href' )
     ))->data;
//打印结果
print_r($data);
在线测试采集并查看采集结果 http: //querylist.cc/page-Querytest.html

点击查看>

在线测试代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$array=[
     [ 'name' => '张三' , 'age' => '23' ],
     [ 'name' => '李四' , 'age' => '64' ],
     [ 'name' => '王五' , 'age' => '55' ],
     [ 'name' => '赵六' , 'age' => '66' ],
     [ 'name' => '孙七' , 'age' => '17' ],
];
$sort = array(
     'direction' => 'SORT_ASC' , //排序顺序标志 SORT_DESC 降序;SORT_ASC 升序
     'field'     => 'age' ,       //排序字段
);
$arrSort = array();
foreach($array as $uniqid => $row){
     foreach($row AS $key=>$value){
         $arrSort[$key][$uniqid] = $value;
     }
}
array_multisort($arrSort[$sort[ 'field' ]], constant($sort[ 'direction' ]), $array);
print_r($array);

点击查看>

中文转拼音工具

1
2
3
4
5
6
7
8
9
10
11
use Overtrue\Pinyin\Pinyin;
$pinyin = new Pinyin();
$pinyin->convert( '带着希望去旅行,比到达终点更美好' );
// ["dai", "zhe", "xi", "wang", "qu", "lv", "xing", "bi", "dao", "da", "zhong", "dian", "geng", "mei", "hao"]
 
$pinyin->convert( '带着希望去旅行,比到达终点更美好' , PINYIN_UNICODE);
// ["dài","zhe","xī","wàng","qù","lǚ","xíng","bǐ","dào","dá","zhōng","diǎn","gèng","měi","hǎo"]
 
$pinyin->convert( '带着希望去旅行,比到达终点更美好' , PINYIN_ASCII);
//["dai4","zhe","xi1","wang4","qu4","lv3","xing2","bi3","dao4","da2","zhong1","dian3","geng4","mei3","hao3"]

点击查看>

因为篇幅的原因,本次的分享就到这里啦,下次讲给大家带来更多php开发实用工具~

猜你喜欢

转载自blog.csdn.net/woshihaiyong168/article/details/75330694