精华内容
下载资源
问答
  • PHP找不到类

    2016-02-26 03:53:52
    .../ddelivery/IntegratorShop.php on line 40 <p>Frankly I never used 'use' declaration before, so it's hard to tell what's wrong. I'm sure it is something obvious. Thanks! </div>
  • php找不到类的解决办法:首先打开错误文件;然后把“try catch”暂时去掉;接着在“new SmsSingleSender()”之前打印include的文件;最后正确使用include即可。本教程操作环境:Windows7系统、PHP5.6版,该方法适用...

    php找不到类的解决办法:首先打开错误文件;然后把“try catch”暂时去掉;接着在“new SmsSingleSender()”之前打印include的文件;最后正确使用include即可。

    29ed2eafc7337633430ed994b799bba8.png

    本教程操作环境:Windows7系统、PHP5.6版,该方法适用于所有品牌电脑。

    具体问题:

    php提示找不到类

    代码如下:(在phpstorm中ctrl+左键都是可以进入到该类的)

    5bbce795e59e8077e20e4fa07185ff67.png

    2e632255e5717a09b6a7c70ce87159a5.png

    使用的腾讯短信sdk,我也没怎么改动呀~,不知道为什么总是报错

    解决办法:

    我上次也遇到过类似的问题,看代码include了该类,但是报错说not found

    你可以在把try.. catch 暂时去掉,在 new SmsSingleSender()之前打印下到底include了哪些文件,echo "

    ";

    print_r(get_included_files());//打印所有加载文件

    exit;

    $ssender = new SmsSingleSender($appid, $appker);

    看看该类到底被include进来没有??

    我上次找到了问题,就是大小写问题,linux严格大小写,而win、mac忽略大小写,导致本应该加载进来的类没加载进来。

    更多编程相关知识,请访问:编程学习!!

    展开全文
  • test1()); class testString extends Father{ public function test1(){ return 1;... 请将父类写子类前面,请在定义以后在实例化 相关标签:php 本文原创发布php中文网,转载请注明出处,感谢您的尊重!

    test1());

    class testString extends Father{

    public function test1(){

    return 1;

    }

    }

    为什么会报错?

    Fatal error: Class 'testString' not found

    如果我去掉extends Father之后就可以正常输出了。

    回复内容:

    test1());

    class testString extends Father{

    public function test1(){

    return 1;

    }

    }

    为什么会报错?

    Fatal error: Class 'testString' not found

    如果我去掉extends Father之后就可以正常输出了。

    第一,从你贴出来的代码看,你应该是写在两个文件之中,在 testString 类文件中没有 require 或 include Father类文件。

    第二,也是你这个问题的关键所在,类声明的顺序,在文件编译过程中,编译到 testString 类声明时,发现没有Father类(即未声明),这时 testString 类声明失败, 这个你可以用class_exists()来验证一下。所以在实例化 testString类的时候报错 class 'testString' not found。

    将父类在继承其的子类之前声明就可以了。

    因为你的定义在调用的后面呀

    肯定错啊。

    顺序执行,testString还没定义,你就new了。

    请将父类写到子类前面,请在定义类以后在实例化

    相关标签:php

    本文原创发布php中文网,转载请注明出处,感谢您的尊重!

    展开全文
  • 我们可以通过两种方式解决命名空间问题第一种方式(Namespace和require)方式Class1.php (Timer Class)namespace Utility;class Timer{public static function {}}Class2.php (Verification Class)namespace Utility;...

    我们可以通过两种方式解决命名空间问题

    第一种方式(Namespace和require)方式

    Class1.php (Timer Class)

    namespace Utility;

    class Timer

    {

    public static function {}

    }

    Class2.php (Verification Class)

    namespace Utility;

    require "Class1.php";

    //Some interesting points to note down!

    //We are not using the keyword "use"

    //We need to use the same namespace which is "Utility"

    //Therefore, both Class1.php and Class2.php has "namespace Utility"

    //Require is usually the file path!

    //We do not mention the class name in the require " ";

    //What if the Class1.php file is in another folder?

    //Ex:"src/utility/Stopwatch/Class1.php"

    //Then the require will be "Stopwatch/Class1.php"

    //Your namespace would be still "namespace Utility;" for Class1.php

    class Verification

    {

    Timer::somefunction();

    }

    第二种方式(使用Composer和自动加载方式)

    Make composer.json file. According to your example “src/Utility”

    We need to create a composer.json file before the src folder. Example: In a folder called myApp you will have composer.json file and a src folder.

    {

    "autoload": {

    "psr-4": {

    "Utility\\":"src/utility/"

    }

    }

    }

    现在转到该文件夹​​打开您的终端,在文件夹位置有composer.json文件.现在输入终端!

    composer dump-autoload

    这将创建供应商文件夹.因此,如果您有一个名为“MyApp”的文件夹

    你会看到vendor文件夹,src文件夹和composer.json文件

    Timer.php(Timer Class)

    namespace Utility;

    class Timer

    {

    public static function somefunction(){}

    }

    Verification.php (Verification Class)

    namespace Utility;

    require "../../vendor/autoload.php";

    use Utility\Timer;

    class Verification

    {

    Timer::somefunction();

    }

    当你有一个复杂的文件夹结构时,这个方法更强大!!

    展开全文
  • 目录controllerlogin.phploginController.phptestsloginTest.php代码详情:loginclass login{// 测试工具PHPUnit要求一定要在这里给变量默认值,于是默认为空。public function login($Sname = "",$Sage = "",$...

    目录

    controller

    login.php

    loginController.php

    tests

    loginTest.php

    edf8086cb4fe8fb604c3a1d5d700e957.png

    代码详情:

    login

    class login

    {

    // 测试工具PHPUnit要求一定要在这里给变量默认值,于是默认为空。

    public function login($Sname = "",$Sage = "",$tableName = "") {

    $con = mysqli_connect("localhost", "root", "root", "yoga_io");

    if (!$con) {

    die('连接失败:' . mysqli_error());

    } else {

    mysqli_query($con, "SET NAMES utf8");

    $result = mysqli_query($con, "SELECT * FROM $tableName where Sname = $Sname and Sage = $Sage");

    if (!$result || mysqli_num_rows($result) == 0) {

    return "false";

    } else {

    $result_arr = mysqli_fetch_assoc($result);

    return json_encode($result_arr, JSON_UNESCAPED_UNICODE);

    }

    }

    }

    }

    loginTest

    use PHPUnit\Framework\TestCase;

    class loginTest extends TestCase

    {

    public function testLoginSuccess() {

    $expected = '{"Sid":"1","Sname":"张三","Sage":"40","Sswx":"男"}';

    $Sname = '张三';

    $Sage = '40';

    $tableName = 'teacher';

    $lg = new Login();

    $actual = $lg->login($Sname,$Sage,$tableName);

    $this->assertEquals($expected,$actual);

    }

    function testLoginFail() {

    $expected = 'false';

    $Sname = '2';

    $Sage = '56';

    $tableName = 'teacher';

    $lg = new Login();

    $actual = $lg->login($Sname,$Sage,$tableName);

    $this->assertEquals($expected,$actual);

    }

    }

    错误信息:

    PHPUnit 8.5.2 by Sebastian Bergmann and contributors.

    Warning: Invocation with class name is deprecated

    EE 2 / 2 (100%)

    Time: 515 ms, Memory: 4.00 MB

    There were 2 errors:

    1) loginTest::testLoginSuccess

    Error: Class 'Login' not found

    C:\Users\Administrator\PhpstormProjects\untitled1\tests\loginTest.php:12

    2) loginTest::testLoginFail

    Error: Class 'Login' not found

    C:\Users\Administrator\PhpstormProjects\untitled1\tests\loginTest.php:25

    ERRORS!

    Tests: 2, Assertions: 0, Errors: 2.

    描述:就是不管换了多少个类做测试就是无法在测试类里面实例化其它类(T T哭了)

    那位大佬遇到过这样的问题吗?能不能指点一下

    展开全文
  • php提示找不到类的解决方法发布时间:2020-11-26 09:41:45来源:亿速云阅读:94作者:栢白今天小编...php找不到类的解决办法:首先打开错误文件;然后把“try catch”暂时去掉;接着在“new SmsSingleSender()”之前...
  • 找不到PHPMailer

    2018-07-24 19:21:43
    <pre><code>Class 'PHPMailer\PHPMailer\PHPMailer' not found </code></pre> <p>Heres the bit of code that im using: <pre><code>use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; ...
  • PHP找不到类错误

    2014-01-24 06:36:30
    This code sends an AJAX call to a PHP class elsewhere in the project named, example.php which contains code to execute a function called, clickFunction() in an Awards.php file, which returns a JSON ...
  • php找不到类

    2012-12-14 13:04:01
    <p>When I run the start.php, I got the message <code>dr1\dr2\testclass.php</code> is not found on <code>start.php</code> on line 5. I could not figure out why. would anybody help. thanks a lot. ...
  • Queue类找不到

    2021-01-03 05:24:48
    <div><p>把Queue移到外边找不到了。。。怎么还发布了个稳定版 <pre><code> PHP Fatal error: Class 'think\queue\Queue' not found in E:\test\tp5\vendor\topt hink\think-queue\src\queue\Worker.php on...
  • <p>At the top of file ReportRequests.php</p> <p>The path : <pre><code>include 'bingads\ReportingClasses.php'; include 'bingads\ClientProxy.php'; </code></pre> <p>was switched to <pre><code>...
  • PHP ZF2:找不到类

    2014-12-07 21:48:48
    I tried adding a require_once for the Version0X php file and it did work, but then it told me that another class which extends Version0X isn't found, so I guessed this will be too much trouble to add ...
  • <p>I'm trying to migrate my App to Google App Engine php7.2. The Main problem is, that sessions are ...<p>I've found a nice Repo that should solve the Problem <a href="https://github.com/tomwalder/...
  • <p><code>Fatal error: Class 'ConfigNamespace' not found in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\MyApplication\libs\config\ConfigParser.php on line 50</code></p> <p>So my ...
  • 找不到PHPMailer”

    2018-06-22 08:56:25
    <p>I'm trying to send my mails via phpmailer. So I placed the <code>Exception.php</code>, <code>PHPMailer.php</code> and <code>SMTP.php</code> into a directory called <code>phpmailer</code>. </p> ...
  • <p>I have a file called <code>Splash\SiteBundle\Util\Resize.php</code> with this namespace <pre><code>namespace Splash\SiteBundle\Util; Class Resize{ ... } </code></pre> <p>Any thoughts? </div>
  • JWT-PHP下载下来后放到thinkphp/library/vendor目录里,在应用里,controller里引用JWT,但是一直报错找不到Firebase/JWT/JWT 。 在调用之前,加: vendor('Firebase.JWT.JWT'); 搞定了。
  • 在本地Windows写完一个Composer包,上传到Linux报错找不到类,纠结了一下午,最后发现是.PHP后缀大写导致的问题。 mv Google2FA.PHP Google2FA.php 转载于:https://www.cnblogs.com/liaozt/p/6263347.html...
  • <p>I am having this problem for my php mailer function. I tried changing the required file but still its the same. Can anyone help me with this error. <p>This is my phpmailer code:</p> <pre><code>$...
  • 可是我明明已经写了Table_yanpan_report_muban 这个数据表函数,为什么提示我找不到呢?郁闷了好久,后来经过查询各种资料找到了问题; 因为我使用了公司框架,引入第三方类库,因为框架规定了文件的命名规则,...
  • 找不到导航

    2019-07-13 09:54:30
    #0 C:\xampp\phpMyAdmin\libraries\classes\Header.php(440): PhpMyAdmin\Navigation\Navigation->getDisplay() #1 C:\xampp\phpMyAdmin\libraries\classes\Response.php(266): PhpMyAdmin\Header->getDisplay...
  • <p>When I try to connect using mysqli I get the following error below <p>Fatal error: class panda\mysqli not found and the line is where it says "new mysqli" when it connects ...
  • <p><strong>Connection.php</strong> <pre><code>namespace Database; class Connection { private static $instance = null; private $pdo; private function __construct() { $this->pdo = new PDO(...
  • <p>I am trying to execute a function inside a Thread though I get the error "Class 'Example' not found" ...<p>Uncaught Error: Class 'SirJoe\Model\Like' not found in lorem-ipsum.php:999</p> </div>
  • <p>demo5.php引用了Query.php 然后访问Query中的方法,页面提示我方法 'table' 在 Database 中未找到 以下是源代码,希望可以帮我检查出错误 第一个是Query.php</p> ...
  • 找不到类继承

    2013-11-16 02:52:30
    odels\Entities\User.php on line 13 </code></pre> <p>I have no idea why I get that error. I have tried calling the "Person" class in many different ways but the its not working. Any idea? Thanks! ...
  • 找不到xml

    2017-06-07 08:05:04
    <p>I am trying to work with fluidxml to test if I can use it, but I cant get it to start working, I am using codeigniter framework. I cloned the repo <a href="https://github.com/servo-...
  • require_once JPATH_LIBRARIES.'/PhpOffice/PhpWord/PhpWord.php'; $Wzor = new \PhpOffice\PhpWord\TemplateProcessor(JPATH_ROOT.'/images/powiadomienia/SzablonPowiadomienia.docx'); </code></pre> <p>But I ...
  • <p><code>grep 'mongo' /etc/php5/cli/php.ini</code> => <code>extension=mongo.so</code></p> <p><code>php -i | grep 'extension'</code> => <code>extension_dir => /usr/lib/php5/20121212 => /...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 907
精华内容 362
关键字:

php找不到类