【发布时间】:2019-05-16 05:51:10
【问题描述】:
我需要你的帮助。 我正在尝试安装 ACF 插件并给我这个错误:
解析错误:语法错误,意外 ':',期待 ';'或 '{' 在 /home/htb/mysite/wp-content/plugins/acf-for-woocommerce/vendor/catsplugins/cp-core/src/common/class-cp-util.php 第 23 行
这是第 23 行:
public static function pathToUrl(string $path): string {
代码如下:
<?php
namespace CastPlugin;
if (class_exists('CpUtil')) {
return;
}
class CpUtil
{
public static function startsWith($haystack, $needle)
{
return strncmp($haystack, $needle, strlen($needle)) === 0;
}
public static function contains($haystack, $needle)
{
return strpos($haystack, $needle) !== false;
}
public static function pathToUrl(string $path): string {
$ssl = @$_SERVER['HTTPS'];
$serverName = $_SERVER['SERVER_NAME'];
$documentRoot = $_SERVER['DOCUMENT_ROOT'];
$correctPath = $path;
$uri = str_replace($documentRoot, '', $correctPath);
$protocol = $ssl === 'on' ? 'https' : 'http';
return "$protocol://$serverName$uri";
}
}
知道如何解决这个问题吗? 谢谢你。 :)
【问题讨论】:
标签: wordpress parsing plugins syntax