刚刚将我的项目移动到另一台PC - 几乎相同的环境: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 - 假设 "CURLOPT_RETURNTRANSFER" in C:''Apache24''htdocs''audiophilesoft.local''vendor''asoft''PersistenceFactory.php:185注意: 使用未定义的常量CURLOPT_SSL_VERIFYPEER - 假设 "CURLOPT_SSL_VERIFYPEER" in C:''Apache24''htdocs''audiophilesoft.local''vendor''asoft''PersistenceFactory.php:185
错误:调用未定义的函数 asoft''curl_init(( C:''Apache24''htdocs''audiophilesoft.local''vendor''asoft''CUrl.php:27 Stack 跟踪:
第 185 行是"受保护的函数句柄缓存(..."如您所见,那里绝对没有常量。
我仅在新PC上遇到此问题。
看起来,问题是PHP和/或Apache文件夹不在Windows包含路径中。