为什么我不能在命名空间中使用CURL?

时间:2016-02-09 22:54:34

标签: php curl

刚刚将我的项目移动到另一台PC - 几乎相同的环境:Windows 10,Apache 2.4,PHP 7.0.3,但突然Curl不想初始化,就像它没有安装一样(但是扩展名是装载)。

我发现它需要反斜杠,如\ curl_init()或\ CURLOPT_RERURNTRANSFER - 但我想知道为什么没有这个在相同环境的另一台PC上工作正常?如何让它在没有这台该死的反斜杠的情况下工作?

public function getCurl(int $instantiate, array $params = [], string $url = ''): CUrl
{
    $args = func_get_args();
    array_shift($args);
    return self::handleCaching($instantiate, 'asoft\\CUrl', ...$args);
}

protected function handleCaching(int $instantiate, string $class, ...$args)
{

    switch ($instantiate) {
        case self::NEW_INSTANCE:
            return new $class(...$args);
        case self::CACHED_INSTANCE:
            if (!array_key_exists($class, self::$cache)) {
                self::$cache[$class] = new $class(...$args);
            }
            return self::$cache[$class];
    }

    throw new EngineError('Wrong value for instantiating type: $instance.');
}
  

注意:使用未定义的常量CURLOPT_RETURNTRANSFER - 假设   'CURLOPT_RETURNTRANSFER'中   C:\ Apache24 \ htdocs中\ audiophilesoft.local \厂商\轻声\ PersistenceFactory.php:185Notice:   使用未定义的常量CURLOPT_SSL_VERIFYPEER - 假设   'CURLOPT_SSL_VERIFYPEER'中   C:\ Apache24 \ htdocs中\ audiophilesoft.local \厂商\轻声\ PersistenceFactory.php:185

     

错误:调用未定义的函数asoft \ curl_init()in   C:\ Apache24 \ htdocs \ audiophilesoft.local \ vendor \ asoft \ CUrl.php:27 Stack   跟踪:

第185行是“受保护的函数handleCaching(...”如你所见,那里绝对没有常量。

我只在新电脑上遇到此问题。

1 个答案:

答案 0 :(得分:0)

看起来,问题是PHP和/或Apache文件夹不在Windows包含路径中。