Home > Backend Development > PHP Tutorial > Yii2 cannot find class using require(__DIR__ . '/../IState.php')?

Yii2 cannot find class using require(__DIR__ . '/../IState.php')?

WBOY
Release: 2016-08-08 09:06:44
Original
1519 people have browsed it

1. Yii2 uses the require() function to import files, but it says that the class cannot be found. Can't it be used this way?

2. If I want to implement the call as shown below, how should I write it?

3. Is there a way to call a folder in Yii2? Yii1 has it. After calling this folder, all the classes and methods contained in this folder can be used.

Supplement: The method in the picture is OK when I use it on ecshop, but the class cannot be found on Yii2.

Yii2 cannot find class using require(__DIR__ . '/../IState.php')?

Reply content:

1. Yii2 uses the require() function to import files, but it says that the class cannot be found. Can't it be used this way?

2. If I want to implement the call as shown below, how should I write it?

3. Is there a way to call a folder in Yii2? Yii1 has it. After calling this folder, all the classes and methods contained in this folder can be used.

Supplement: The method in the picture is OK when I use it on ecshop, but the class cannot be found on Yii2.

Yii2 cannot find class using require(__DIR__ . '/../IState.php')?

Obviously there is a problem with your classpath, use namespaces to deal with it.

Related labels:
php
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