PHP杂记

SOAP:

感觉是类似于Java中的HttpClient的东西,和curl也有点像。

 

PHPStorm中查看所有的函数结构(Structure):Alt+7

structure

 

查找方法或类(Symbol Name 函数/方法名):Ctrl+Shift+Alt+N

symbol

 

代码折叠 展开 (Collapse/Expand)

 collapse

 

让PHPStorm支持CodeIgniter中某些不识别的类和变量:

在system/core 的Controller和Model.php的CI_Controller和CI_Model类前加上类似这样的注释:

@property CI_DB $db
@property CI_Model $model
@property CI_Input $input
@property CI_Output $output

php

另据维基百科中的phpstorm条目

“PHPDoc support. The IDE provides code completion suggestions based on @property, @method and @var annotations. ”。

另据http://www.kuitao8.com/20141010/3137.shtml

第一类是文件中的变量声明,比如在某个代码文件中声明了变量$category,我们可以在这个代码文件的开头部分用注释的方式申明一个指示器告诉PhpStorm变量的类型,就像下面这样:

/* @var $category Category */

有了这个注释,PhpStorm能够自动查找Category类的声明文件,编码过程中PhpStorm就能直接提示。

第二类是类的属性申明指示,还是以Category类的声明为例,可以在类的上部声明指示器,说明类的属性以及属性的类型,编码方式如下:

/**

* @property string $name

*/

class Category

{}

PhpStorm能够识别Category具有属性$name。

第三类是循环,函数,条件结构内部的变量指示,我们以foreach循环为例,可以通过如下的方式声明类型指示:

foreach($categories as $category)

{

    /* @var $category Category */

    $category->name

}

有了上面的指示,在循环结构的内部就能方便地使用代码提示了。

Google Chrome 插件位置:

C:\Users\bibiFM\AppData\Local\Google\Chrome\User Data\Default\Extensions

EasyUI form load 方法

可以把json数据装入到页面上的form表单中。

文档:

http://jeasyui.com/documentation/form.php

load data Load records to fill the form. The data parameter can be a string or a object type, when string acts as a remote URL, otherwise acts as a local record.

Code example:

$('#ff').form('load','get_data.php');	// load from URL
$('#ff').form('load',{
	name:'name2',
	email:'mymail@gmail.com',
	subject:'subject2',
	message:'message2',
	language:5
});

load

 

CI框架 数据库查询 示例

 1 <?php
 2 // 声音管理控制器
 3 // by HapLeo 20150609
 4 defined('BASEPATH') OR exit('No direct script access allowed');
 5 
 6 class Beat extends CI_Controller
 7 {
 8     function __construct()
 9     {
10         parent::__construct();
11         $this->load->model("public_model", "Public");
12     }
13 
14 
15 
16     //声音列表页面
17     public function index()
18     {
19         $this->load->view("Beat/index");
20     }
21 
22     //声音列表数据
23     public function info()
24     {
25         $page = $this->input->post('page');//页码
26         $rows = $this->input->post('rows');//每页显示条数
27         $offset = ($page - 1) * $rows;//计算分页偏移值
28 
29         if (isset($_POST['title'])) {
30             $title = $this->input->post('title', true);
31             $this->db->like('title', $title);
32         }
33 
34         $this->db->select("b.id,b.title,b.anonymous,b.releasetime,c.title category");
35         $this->db->from('bed_beat b');
36         $this->db->join("bed_category c","c.id = b.categoryid",'left');
37         $this->db->order_by("b.releasetime",'DESC');
38 
39         //获取结果总数
40         $count = $this->db->count_all_results('',false);
41 
42         //分页
43         $this->db->limit($rows,$offset); //没有写反。
44         //返回结果
45         $result = $this->db->get()->result_array();
46         /*//处理排序
47         $arr = array();
48         $num = 0;
49         foreach ($query as $k => $v) {
50             $arr[$num] = $v;
51             $num++;
52             if (isset($_POST['title'])) {
53                 $title = $this->input->post('title', true);
54                 $this->db->like('title', $title);
55             }
56             $this->db->order_by("sort", "desc");
57             $this->db->where("pid", $v['id']);
58             $queryc = $this->db->get("menu")->result_array();
59             foreach ($queryc as $k1 => $v1) {
60                 $arr[$num] = $v1;
61                 $num++;
62             }
63         }*/
64 
65         $list['rows'] = $result;
66         $list['total'] = $count;
67         $result = $this->Public->jsonEncodeWithCN($list);
68         echo $result;
69     }
70 
71 
72 
73     //行编辑
74     public function edit()
75     {
76         $this->load->view("Beat/form");
77     }
78 }

Fiddler 4

一个看请求的,类似于抓包的软件……

可以设置为浏览器的代理……

感觉不错……

PHP与Java及JS的异同

PHP的变量不用声明,但是都要以$开头。

数组也可以直接拿来就赋值,比如$a['b']=3

posted @ 2015-06-04 10:45  过客代码站  阅读(251)  评论(0编辑  收藏  举报