一、示例代码 runtime.php 主要 3个部分, 1、定义系统目录和项目目录 // 路径设置 可在入口文件中重新定义 所有路径常量都必须以/ 结尾defined(CORE_PATH) or define(CORE_PATH, THINK_PATH.Lib/); // 系统核心类库目录defined(EXTEND_PATH) or define(EXTEN
一、示例代码
runtime.php 主要 3个部分,
1、定义系统目录和项目目录
// 路径设置 可在入口文件中重新定义 所有路径常量都必须以/ 结尾 defined('CORE_PATH') or define('CORE_PATH', THINK_PATH.'Lib/'); // 系统核心类库目录 defined('EXTEND_PATH') or define('EXTEND_PATH', THINK_PATH.'Extend/'); // 系统扩展目录 defined('MODE_PATH') or define('MODE_PATH', EXTEND_PATH.'Mode/'); // 模式扩展目录 //省略 defined('TEMP_PATH') or define('TEMP_PATH', RUNTIME_PATH.'Temp/'); // 项目缓存目录 defined('DATA_PATH') or define('DATA_PATH', RUNTIME_PATH.'Data/'); // 项目数据目录 defined('CACHE_PATH') or define('CACHE_PATH', RUNTIME_PATH.'Cache/'); // 项目模板缓存目录
2、载入核心类和基础函数库(common.php)
// 加载系统基础函数库 require THINK_PATH.'Common/common.php'; // 读取核心文件列表 $list = array( CORE_PATH.'Core/Think.class.php', CORE_PATH.'Core/ThinkException.class.php', // 异常处理类 CORE_PATH.'Core/Behavior.class.php', ); // 加载模式文件列表 foreach ($list as $key=>$file){ if(is_file($file)) require_cache($file); }
3、创建项目目录
if(!is_dir(LIB_PATH)) { // 创建项目目录结构 build_app_dir(); } /*Runtime目录不存在则重新创建Runtime目录*/ elseif(!is_dir(CACHE_PATH)){ // 检查缓存目录 check_runtime(); }elseif(APP_DEBUG){ // 调试模式切换删除编译缓存 if(is_file(RUNTIME_FILE)) unlink(RUNTIME_FILE); }
最后就是调用 Think.class.php 中的
Think::Start();
二、值得说的编程小细节:
// 为了方便导入第三方类库 设置Vendor目录到include_path set_include_path(get_include_path() . PATH_SEPARATOR . VENDOR_PATH);举例: some.class.php 在 /a/b/c/include 目录下
那么在 引入类文件 include '/a/b/c/include/some.class.php';
如果定义了 set_include_path('/a/b/c/include');
只需 include 'some.class.php'; 即可

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools

Dreamweaver CS6
Visual web development tools

SublimeText3 Chinese version
Chinese version, very easy to use
