PHP 文件中无法识别方法和变量

问题描述 投票:0回答:1

晚上好,

为了在 Ubuntu 22.04 上使用模型-视图-控制器架构编写 PHP 应用程序,我首先学习创建供应商文件夹。在这个文件夹中,还有另一个名为composer的文件夹,其中的ClassLoader类、两个方法(acpu_fetch和apcu_add)和一个变量($hit)无法识别。 php8.1-acpu包已正确安装。运行 php -m 时会列出此包。 在此消息的附件中,您将找到“phpinfo.php”文件。 感谢您的帮助! phpinfo.php

我卸载了apcu软件包,然后重新安装了它。我在 Linux Mint 上尝试了相同的程序并遇到了同样的问题。 /etc/php/8.1/mods-available/apcu.ini 包含

extension=apcu.so
php composer-php apcu
1个回答
0
投票

这是程序中出现问题的部分: '''

/**
     * Finds the path to the file where the class is defined.
     *
     * @param string $class The name of the class
     *
     * @return string|false The path if found, false otherwise
     */
    public function findFile($class)
    {
        // class map lookup
        if (isset($this->classMap[$class])) {
            return $this->classMap[$class];
        }
        if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
            return false;
        }
        if (null !== $this->apcuPrefix) {
            $file = apcu_fetch($this->apcuPrefix.$class, $hit);
            if ($hit) {
                return $file;
            }
        }

        $file = $this->findFileWithExtension($class, '.php');

        // Search for Hack files if we are running on HHVM
        if (false === $file && defined('HHVM_VERSION')) {
            $file = $this->findFileWithExtension($class, '.hh');
        }

        if (null !== $this->apcuPrefix) {
            apcu_add($this->apcuPrefix.$class, $file);
        }

        if (false === $file) {
            // Remember that this class does not exist.
            $this->missingClasses[$class] = true;
        }

        return $file;
    }
'''
If you want the complete class, ask me
    
© www.soinside.com 2019 - 2024. All rights reserved.