我怎么才能修复代码中的错误,我找不到关于如何修复它的解释,ı如果像我这样的人遇到了这样的问题,ı等待你的帮助
class JSMin {
const ORD_LF = 10;
const ORD_SPACE = 32;
const ACTION_KEEP_A = 1;
const ACTION_DELETE_A = 2;
const ACTION_DELETE_A_B = 3;
protected $a = '';
protected $b = '';
protected $input = '';
protected $inputIndex = 0;
protected $inputLength = 0;
protected $lookAhead = null;
protected $output = '';
// -- Public Static Methods --------------------------------------------------
/**
* Minify Javascript
*
* @uses __construct()
* @uses min()
* @param string $js Javascript to be minified
* @return string
*/
public static function minify($js) {
$jsmin = new JSMin($js);
return $jsmin->min();
}发布于 2021-07-15 14:42:15
这里有几个注意事项:
的存档git
rgrove/jsmin-php作者已经将其存档,并敦促不要再使用它,并建议使用其他更好的解决方案。
可能性ONE
然而,如果你打算继续使用它,你可以用如下的命名空间来修改它-假设opencart真的已经在它的本机代码中声明了它:
<?php
namespace DeprecatedDontUse;
class JSMin
{
const ORD_LF = 10;
const ORD_SPACE = 32;
const ACTION_KEEP_A = 1;
const ACTION_DELETE_A = 2;
const ACTION_DELETE_A_B = 3;
protected $a = '';
protected $b = '';
protected $input = '';
protected $inputIndex = 0;
protected $inputLength = 0;
protected $lookAhead = null;
protected $output = '';
....etc然后,当你使用它时,你会这样做:
<?php echo \DeprecatedDontUse\JSMin::minify($JSstring) ?>这应该会解决重复的类命名问题。
可能性两个
如果您没有以某种方式将这个类自动加载到您的应用程序中,而是手动将其包含在一个文件中,那么您只需将脚本保持原样(没有名称空间),而不是使用require('/path/to/jsmin.php');或include('/path/to/jsmin.php'); (无论您使用哪个),您将使用这些类的once版本,因此可以使用include_once('/path/to/jsmin.php');或require_once('/path/to/jsmin.php');。
这是为了防止opencart在整个执行过程中多次加载您要添加的脚本。它只会加载一次类,并且不会给你这个错误。
https://stackoverflow.com/questions/68379022
复制相似问题