刚刚将我的项目移到了几乎相同的环境:Windows 10,Apache 2.4,PHP 7.0.3,但是突然Curl不想初始化,就像没有安装(但是加载了扩展程序)一样。
我发现它需要反斜杠,例如\ curl_init()或\ CURLOPT_RERURNTRANSFER-但我想知道为什么在没有其他相同环境的PC上可以正常工作吗?以及如何在新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-在C:\ Apache24 \ htdocs \ audiophilesoft.local \ vendor \ asoft \ PersistenceFactory.php:185中假定为'CURLOPT_RETURNTRANSFER' htdocs \ audiophilesoft.local \ vendor \ asoft \ PersistenceFactory.php:185
错误:调用C:\ Apache24 \ htdocs \ audiophilesoft.local \ vendor \ asoft \ CUrl.php:27中未定义的函数asoft \ curl_init():堆栈跟踪:
第185行是“受保护的函数handleCaching(...)”,如您所见,那里绝对没有常量。
我只有在新PC上才有此问题。
看来,问题出在Windows包含路径中没有PHP和/或Apache文件夹。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句