## 類自動載入
~~~
?<?php
?/**
? * Created By basic
? * Author: Virus
? * Date: 2020/5/24
? * Time: 13:14
? */
??
?// 這里可以寫多個自動加載方法
?spl_autoload_register('autoload1');
??
?function autoload1($class)
?{
? ? ?require __DIR__.'/'.$class.'.php';
?}
~~~
## PSR-0規范
1. 命名空間必須與絕對路徑一致
2. 類名首字母必須大寫
3. 出入口文件外,其他“.php”必須只有一個類
> 一個簡易的PSR-0實現的框架目錄結構

`index.php`入口文件
~~~
?<?php
?/**
? * Created By basic
? * Author: Virus
? * Date: 2020/5/24
? * Time: 13:20
? */
??
?// 定義基礎路徑
?define('BASEDIR', __DIR__);
??
?include BASEDIR.'/Base/Loader.php';
??
?spl_autoload_register('\\Base\\Loader::autoload');
??
?App\Controller\Home\Index::test();
~~~
`Loader.php`加載類
~~~
?<?php
?/**
? * Created By basic
? * Author: Virus
? * Date: 2020/5/24
? * Time: 13:24
? */
?namespace Base;
?class Loader
?{
? ? ?public static function autoload($class)
? ? {
? ? ? ? ?// 需要將反斜杠換成斜杠
? ? ? ? ?require BASEDIR.'/'.str_replace('\\', '/', $class).'.php';
? ? }
?}
~~~
## PHP的鏈式操作的實現
~~~
?<?php
?/**
? * Created By basic
? * Author: Virus
? * Date: 2020/5/24
? * Time: 14:16
? */
??
?namespace Base;
??
??
?class Database
?{
? ? ?function where($where)
? ? {
? ? ? ? ?return $this;
? ? }
??
? ? ?function order($order)
? ? {
? ? ? ? ?return $this;
? ? }
??
? ? ?function limit($limit)
? ? {
? ? ? ? ?return $this;
? ? }
?}
~~~
~~~
?$db = new \Base\Database();
??
?// 傳統代碼步驟
?//$db->where('id=1');
?//$db->where("name=2");
?//$db->order("id desc");
?//$db->limit(10);
??
?// 鏈式操作
?$db->where("id=1")->where("name=2")->order("id desc")->limit(10);
~~~
- PHP獲取客戶端瀏覽器信息和版本
- PHP獲取客戶端操作系統信息
- 無限級分類
- git使用
- 權限檢測思路
- Vue學習
- 遇到的一些問題
- PHP的編碼思維和技巧
- mysql復習
- tp5
- ThinkPHP5.x 公共函數
- TP5登錄注冊
- TP5使用模板繼承
- ThinkPHP5.1 清除緩存
- thinkphp5實現安裝程序
- 安全
- tp中實現跨域代碼
- ThinkPHP5.1配合pjax實現菜單欄無刷新跳轉
- 獲取數據庫版本和數據庫大小
- 模型的基本CURD操作
- 商品spu
- 全局異常處理類
- ExceptionHandler
- BaseException
- PHP函數之error_reporting(E_ALL ^ E_NOTICE)詳細說明
- 微信小程序
- wx:for
- tp6
- 分離的一些模塊
- session開啟
- Spring
- 依賴注入
- 數據結構
- 二叉樹
- js獲取地址欄變量
- PHP設計模式
- 面向對象
- PHP1
- PHP性能優化
- Java學習
- static關鍵字
- 多態
- 接口、階乘
- 大佬給的面試題
- 訪問量為5000萬的博客系統設計
- PHP可變參數
- Nginx的配置案例
- 求數組中的最大值,并返回數組索引
- PHP面試方向
- PHP數組工具類ArrUtil
- 字符串工具類StrUtil
- PHP使用curl發送請求
- mysql
- PHP上傳base64圖片處理函數
- webstorm小程序常用配置
- 郵箱正則表達式
- leetcode mysql記錄
- 函數庫