thinkphp5.1怎么引用外部文件

PHPz
Release: 2020-06-28 09:41:00
Original
2247 people have browsed it

thinkphp5.1怎么引用外部文件

thinkphp5.1怎么引用外部文件?

首先将引用的外部类文件放入extend目录下

为了方便记录所用的功能对应的类文件(如Alipays.php),可以在extend文件下新建一个文件夹如lib

然后将类文件放入lib文件下,此时关键步骤开始了,

1、将该类文件的命名空间改为namespace lib;

2、在您开发的文件下如(Paymusic.php)引入该类文件,代码如下

require './extend/lib/Alipays.php';或者require '../extend/lib/Alipays.php';

use lib\Alipays;

此刻类文件已经引入进来

3、$alipay= new Alipays();

4、dump($alipay);die;来验证是否成功。

结束

本人就是这样引入的该文件。如果您还是没有引入进来的话,可以给我留言;

更多相关技术文章,请访问PHP中文网

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!