search
Homephp教程php手册ThinkPHP公共配置文件与各自项目中配置文件组合的方法

这篇文章主要介绍了ThinkPHP公共配置文件与各自项目中配置文件组合的方法,涉及array_merge函数将多个数组合并的方法,是ThinkPHP项目开发中非常实用的技巧,需要的

本文实例讲述了ThinkPHP公共配置文件与各自项目中配置文件组合的方法。分享给大家供大家参考。具体实现方法如下:

在使用ThinkPHP时,在布局目录时,常使用的是单个入口文件对应一个项目目录,但是这样在写配置文件时,在各自的配置文件中,经常会使用重复的配置项,所用这时就会将公共的配置项放在一个公共的目录下。

具体实现方法:

使用配置文件的特性return array();可以在各自项目中的配置文件中这样定义:

复制代码 代码如下:

$config = array(''=>'',);

然后使用函数

复制代码 代码如下:

return array_merge(include'./conf/config.php',$config);

这样就可以在最根目录下面使用公共的配置文件

希望本文所述对大家的ThinkPHP框架程序设计有所帮助。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),