亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

快速入門ThinkPHP 5.0--基礎篇

難度中級
時長 5小時20分
學習人數
綜合評分9.63
150人評價 查看評價
9.8 內容實用
9.6 簡潔易懂
9.5 邏輯清晰
  • tp\thinkphp\Request.php文件有所以的請求方法 //獲取當前是哪個模塊\控制器\操作 再操作,用于調試 dump($request->module()); dump($request->controller()); dump($request->action()); dump($request->url());//當前.URL ./index/Index/index/type/5.html?id=10 dump($request->baseUrl());//不用?號后的參數
    查看全部
  • //獲取域名\路由\地址 use think\Request public function index(Request $request){ dump($request->domain());//http://jianpf.com dump($request->pathinfo());//index/index/index.html dump($request->path());//index/index/index //請求類型 dump($request->method());//GET請求 dump($request->isGet());//GET請求true dump($request->isPost());//POST請求true dump($request->isAjax());//AJAX請求true //獲取請求的參數 dump($request->get());//tp5開始get數組沒有了pathinfo等信息,只有參數的數組 dump($request->param());//方法名也放數組中 dump($request->post()); //使用session需要開啟session //tp\thinkphp\convent.php下的第198行session=>['auto_start'=>ture]和刪除session安全'httpponly'和'secure'配置 dump($request->session());//session('name','jianpf');session助手函數 dump($request->cookie());//cookie('email','[email protected]');cookie助手函數 dump($request-param('name'));//獲取單個值 dump($request->session('name'));//獲取單個值 dump($request->cookie('name'));//獲取單個值
    查看全部
  • tp\public\index.php tp\thinkphp\start.php tp\thinkphp\base.php namespace thinkphp;\\對應于tp\thinkphp\library App::run()->send();\\對應于tp\thinkphp\library\App.php //run()方法只執行一次 /** * 執行應用程序 * @access public * @param Request $request Request對象 * @return Response * @throws Exception */ public static function run(Request $request = null) { is_null($request) && $request = Request::instance(); try { $config = self::initCommon(); if (defined('BIND_MODULE')) { // 模塊/控制器綁定 BIND_MODULE && Route::bind(BIND_MODULE); } elseif ($config['auto_bind_module']) { // 入口自動綁定 $name = pathinfo($request->baseFile(), PATHINFO_FILENAME); if ($name && 'index' != $name && is_dir(APP_PATH . $name)) { Route::bind($name); } }
    查看全部
  • tp請求對象獲取 request()老忘記request和response //方法注入請求 public function index(Request $requests){dump($request)} 助手函數request();//返回的是個對象 使用use think\Request; $res=Request::instance();//放回的是哥對象
    查看全部
    0 采集 收起 來源:請求對象獲取

    2017-05-31

  • tp\application\index\controller\Index.php下添加方法 public function info($id){return "{$id}"} tp\application\conf\route.php文件定義路由 <? return ['news/:id'=>'index/index/info'] //tp\thinkphp\convention.php文件是否開啟路由 'url_routeion'=>true,//85行 'url_route_must'=>false//強制使用路由(靜態路由,必須有路由,否則報錯找不到) //啟用路由可以用url()函數返回路由URL地址 echo url('index/index/index',['id'=>10]).'<br/>' 輸出/index/Index/index/id/10 echo url('index/index/info',['id'=>10]).'<br/>' 輸出/news/10.html
    查看全部
    1 采集 收起 來源:路由

    2018-03-22

  • tp\public\index.php入口文件指定默認模塊 define('BIND_MODULE','admin');//綁定admin模塊 define('BIND_MODULE','admin\index');//綁定admin模塊index.php文件(只能傳遞方法),URL:localhost\User\index會報錯admin\index.php中沒有User->index方法 //給網站添加API tp\public\api.php內容: <?php define("APP_PATH",__DIR__.'/../app/'); define("CONF_PATH",__DIR__.'/../conf/'); define("BIND_MODULE",'api');//tp\application\api\controller\index.php require(__DIR__.'/../thinkphp/stat.php'); tp\thinkphp\convention.php慣例配置的auto_bind_module=>true 就可以不用在入口文件define("BIND_MODULE",'api');//直接按照http://localhost/api.php的文件綁定模塊,不能訪問其他模塊
    查看全部
  • MAMP啟用Apache的隱藏入口文件URL重寫規則 \mamp\config\apache\httpd.conf文件 第130行 rewrite_module 打開LoadModule rewrite_module modules/mod_rewrite.so 第239行 網站的目錄地址下 AllowOverride None 改成 AllowOverride All 重啟MAMP服務器 URL重寫規則啟用tp\public\.htaccess文件重寫的,沒有就報錯Not Found
    查看全部
    0 采集 收起 來源:隱藏入口文件

    2017-05-31

  • tp5的但入口文件,大廈的入口,由寶安指路 tp\public\index.php tp\application應用目錄 tp\conf全局配置目錄 tp\extend全局拓展配置目錄 tp\thinkphp\base.php基本配置文件 tp\thinkphp\start.php安全過濾
    查看全部
    0 采集 收起 來源:隱藏入口文件

    2017-05-31

  • dump(\think\Env::get('status'));//獲取單個.env變量 tp\.env內容 status=dev//環境變量識別場景配置 (線上線下開發) //判斷開發環境 $res=Env::get('status','prod');//PHP_STATUS=prod標記 tp/application/conf/config.php內容: <?php //導入Env類(這里是重點...) use think\Env; return ['app_status'=>Env::get('app_status','dev')];//沒有就讀tp/application/conf/dev.php配置文件 dump(config());
    查看全部
  • //Env系統函數 use think\Env; $res=Env::get('email');//下標小寫 $res=Env::get('email不存在');//返回NULL值 $res=Env::get('email不存在','直接返回此值'); //Env支持點語法 $res=Env::get('database_hostname'); $res=Env::get('database.hostname'); //打印系統環境變量 dump($_ENY); //自定義系統環境變量 tp/.env內容 [email protected] database_hostname=localhost database_username=root database_password=root #分組等效 [database] hostname=localhost username=root password=root dump($_ENV['PHP_EMAIL'])//下標變大寫 //只輸出['PHP_EMAIL']=>string(15)
    查看全部
  • //實例化當前所給位置下的Yndex.php對象$a $a=new Yndex(); //調用Yndex.php對象的方法jpf(); return $a->jpf();
    查看全部
  • tp的::雙冒號是靜態方法 $res=Config::has('app_debug');//tp/thinkphp/convention.php慣例配置文件 tp\thinkphp\library\think\config.php /** * 檢測配置是否存在 * @param string $name 配置參數名(支持二級配置 .號分割) * @param string $range 作用域 * @return bool */ public static function has($name, $range = '') { $range = $range ?: self::$range; if (!strpos($name, '.')) { return isset(self::$config[$range][strtolower($name)]); } else { // 二維數組設置和獲取支持 $name = explode('.', $name, 2); return isset(self::$config[$range][strtolower($name[0])][$name[1]]); } }
    查看全部
  • tp\thinkphp\helper.php助手函數初始化文件 /** 判斷助手函數是否不存在用戶函數 */ if (!function_exists('config')) { /** * 獲取和設置配置參數 * @param string|array $name 參數名 * @param mixed $value 參數值 * @param string $range 作用域 * @return mixed */ function config($name = '', $value = null, $range = '') { if (is_null($value) && is_string($name)) { return 0 === strpos($name, '?') ? Config::has(substr($name, 1), $range) : Config::get($name, $range); } else { return Config::set($name, $value, $range); } } } //注意::Config是首字母大寫 Config::get('配置名'); config('配置名','配置值','配置作用域標記是否一樣'); config('?配置名值是否不為null');
    查看全部
  • config類和config助手函數 tp\thinkphp\library\think\Config.php文件 range()方法:設置配置參數的作用域 parse()方法:解析配置文件或內容 load()方法:加載配置文件(PHP格式) has()方法:檢測配置是否存在 get()方法:獲取 set()方法:設置 reset()方法:重置配置 1.加載助手類,并使用框架助手函數 use think\Config; $res=Config::get(); 2.全路徑指向類,并使用框架助手函數 $res=\think\Config::get(); 3.助手函數(不一定是框架助手類)$res=config(); dump($res);
    查看全部
  • 動態配置config()函數 //01魔術方法:類自動加載方法 public function __construct(){config('before','beforeAction');//動態配置} //修改配置(簡單連接MYSQL數據庫) \think\Config::set('database.type','mysql');//連接MYSQL \think\Config::set('database.database','test');//數據庫名 \think\Config::set('database.username','root');//MYSQL用戶 \think\Config::set('database.prefix','');//表前綴 $data = ['字段1' => '值1', '字段2' => '值2']; $res=\think\Db::table('表名')->insert($data);//插入數據 dump($res); $res=\think\Db::table('表名')->select();//查詢數據 dump($res);
    查看全部
    0 采集 收起 來源:動態配置

    2018-03-22

舉報

0/150
提交
取消
課程須知
1、有一定的php基礎。 2、對git composer 有一定的了解。 3、本機安裝好相應的開發環境 4、最好有一定的mvc 框架的使用經驗
老師告訴你能學到什么?
1、框架的搭建 2、目錄文件的介紹 3、環境的配置 (開發 測試 線上環境) 4、請求對象和數據請求參數獲取 5、相應對象和返回相應類型的數據 6、模板的使用 比較 判斷 循環

微信掃碼,參與3人拼團

微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網的支持!