搬磚筆記 初識CI框架

2021-09-25 20:43:53 字數 2441 閱讀 4893

2023年8月2日 天氣晴

本文將淺顯的介紹ci框架的接收跳轉載入;詳情請參考ci手冊輸入類

$this->input->post('name');

//括號中的name為欲接受的post中的值,若資料不存在方法將返回false

$this->input->post('name',boolean);

//第二個引數是可選的,如果想讓取得的資料經過跨站指令碼過濾,把第二個引數設定為true

$this->input->post();

//(不設定任何引數,該方法將以陣列的形式)返回過來全部的post資料,且不經過跨站指令碼過濾

$this->input->get();

$this->input->get('name');

$this->input->get('name',boolean);

//get的用法與post一樣

$this->input->get_post('name',boolean);

//該方法將會搜尋get和post方式傳過來的資料流,先以post方式搜尋,再以get方式搜尋

$this->input->cookie('name',boolean);

$this->input->server('name',boolean);

//此方法類似post和get的獲取方式

設定cookie的值

$this->input->set_cookie();

//該函式接受兩種形式的引數

//1.陣列(用陣列形式,傳遞的是乙個關聯陣列)

$cookie = array(

'name' => 'the cookie name',

'value' => 'the value',

'expire' => '86500',

'domain' => '.some-domain.com',

'path' => '/',

'prefix' => 'myprefix_',

'secure' => true

);$this->input->set_cookie($cookie);

刪除cookie:可以通過將 expire 設定成空來實現刪除cookie的操作

1.1 如果expire設定成0,那麼cookie僅在瀏覽器關閉時失效

//2.引數

$this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);

site_url()和base_url()的區別

假如你config檔案裡面的base_url和index_page是這樣定義的:

config['base_url'] = "";

config['index_page'] = "index.php";

那麼你若使用site_url(「news/php/2」);則實際url為

index.php/news/php/2

若使用base_url(「news/php/2」);則url為:

news/php/2

發現沒有,base_url()少了乙個index.php

在ci框架中做跳轉的方法

header(「location:」.site_url(「common/login」));

帶引數跳轉

';

>

修改

超連結跳轉

">

**商管理

reurl()這個方法只是將傳入的url返回而已

$this->input->model(『modelname』);

$this->input->model(『blog/queries』);

模型一旦被載入,可以使用下面的方法呼叫他

$this->load->model('model_name');

$this->model_name->functionname();

新大陸

使用三元運算子定義常量

define('_company_id_', $_session['userid'] ? $this->user_model->admin_company($_session['userid']) : 0);

搬磚筆記 CRLF注入

crlf 指的是回車符 cr,ascii 13,r,0d 和換行符 lf,ascii 10,n,0a windows 使用crlf表示行的結束 linux unix 使用lf表示行的結束 macos 早期使用cr表示,現在好像也用lf表示行的結束 在http報文結構中,狀態行和首部中的每行都是以cr...

搬磚筆記 常用PHP函式

對陣列按照鍵名排序,保留鍵名到資料的關聯。本函式主要用於關聯陣列。bool ksort array array int sort flags sort regular ksort fruits foreach fruits as key val 輸出結果 a orange b banana d le...

搬磚筆記 錯題集

file 官方解釋 檔案的完整路徑和檔名。如果用在被包含檔案中,則返回被包含的檔名。個人理解 輸出檔案的絕對路徑,一直到檔名為止 d 0 9 d 0 9 以外的 s t n f v 空白 s t n f v 空白以外的 w a za z0 9 w a za z0 9 以外的 mysql pconne...