ecshop警告

ecshop在在PHP5.6.6版本以后,有了很多细微的变化。

http://bbs.ecshop.com/thread-95341-1-1.html

ECSHOP官方更新又太慢,发现这些问题后也不及时升级,导致用户安装使用过程中错误百出。

最模板整理一下我遇到的问题希望对你们能有些帮组也为了自己以后查看。

问题1:     

  Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in cls_template.PHP XXX line

出错原因:

   出现以上问题是 preg_replace() 函数中用到的修饰符 /e 在 PHP5.5.x 中已经被弃用了。在PHP 5.5以上的版本用 preg_replace_callback 函数替换了 preg_replace函数。

解决方法:

 解决问题的方法就是将代码中使用 preg_replace 函数的部分全部替换成 preg_replace_callback 函数,并且将一被废弃的 /e 修饰符 删除。 

例子: 

   return preg_replace("/{([^\}\{\n]*)}/e", "\$this->sel ect('\\1');", $source); 

   替换为

   return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->sel ect($r[1]); }, $source);

 

问题2:

   Strict Standards: Only variables should be passed by reference in ......\includes\cls_template.php on line 418

出错原因:

   出现这个问题的原因,貌似在php5.4中array_shift只能为变量,不能是函数返回值。

解决方法:

   $tag_sel = array_shift(explode(‘ ‘, $tag));

   替换成

   $tag_arr = explode(‘ ‘, $tag);
   $tag_sel = array_shift($tag_arr);

 

问题3: 

   Strict Standards: Non-static method cls_image::gd_version() should not be called statically in ......\includes\lib_base.php on line 346   或者

   Strict Standards: Non-static method cls_image::gd_version() should not be called statically in ......\includes\lib_installer.php on line 31

出错原因:  //www.zuimoban.com

   如问题中提示的一样,因为 cls_image.php 中 gd_version() 不是 static 函数所以在lib_base.php 与 lib_installer.php 中调用时才会出现以上问题。

解决方法:

  解决方法1:    首先在 lib_image.php 文件中,用 Shift+F 去搜索 gd_version 函数。然后在gd_version 方法前加 static 修饰符,是此函数变成静态函数。

    解决方法2:    在lib_base.php 与 lib_installer.php 函数中找到 cls_image::gd_version() 部分, 然后分别创建cls_image 实例,之后用创建的实例再去调用 gd_version() 函数。

                      $cls_gile = new cls_image();

                      return $cls_gile->gd_version();

553行  // $val = preg_replace_callback("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);

            $val = preg_replace_callback("/\[([^\[\]]*)\]/", function($r) {return '.'.str_replace('$','$',$r[1]);}, $val);

问题4:

   Deprecated: Assigning the return value of new by reference is deprecated in…

出错原因:

   PHP5.3+废除了”=&”符号,对象复制用”=”

解决方法:

   搜索所有PHP文件,将”=&”替换为”=”


问题5:

   Strict Standards: mktime(): You should be using the time() function instead in ......\admin\shop_config.php on line 32

出错原因:

   这个错误提示的意思:mktime()方法不带参数被调用时,会被抛出一个报错提示。

解决方法:

   $auth = mktime();

   将mktime()替换成time()方法,代码为:

   $auth = time();

 

问题6:

   Strict Standards: Redefining already defined constructor for class cls_sql_dump ......

出错原因:

   原因跟PHP类中的构造函数有关,PHP早期版本是使用跟类同名的函数作为构造函数,后来又出现了使用 __construct()作为构造函数,

   这俩个函数可以同时存在。到了PHP5.4版本,对这俩个函数在代码中的先后顺序有了严格的要求。在PHP5.4版本下,必须__construct() 在前,

   同名函数在后,否则就会出现上面的的错误提示。

解决方法:

   把__construct()函数放在,同名函数上面就行了。

 

问题7:

   Strict Standards: Declaration of vbb::set_cookie() should be compatible with integrate::set_cookie($username = '', $remember = NULL)

出错问题:

   vbb继承了integrate类并且重写了 set_cookie() 函数,但vbb重写set_cookie函数的参数 与 其父类set_cookie 的参数不符所以出现以上问题。

解决方法:

   function set_cookie ($username="")
   改为
   function set_cookie ($username="", $remember = NULL)

   如出现类似错误,可以以同样的方法解决。

 

*Alipay等错误提示是,因为构造函数和 类同名够着函数位置先后反一下

 function __construct()   //先

    {

        $this->alipay();

    }

function alipay()  //后

    {

}

*还有good_batch.php中 $filter = &new stdclass;的 &去掉

 

*cls_template.php  497错误preg_replace错误提示

ECS前台出现cls_template.php on line 493,求解决办法!!!

 分享| 2015-09-13 16:14匿名 | 浏览 436 次  悬赏:10

 PHP

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in D:\xampp\htdocs\includes\cls_template.php on line 493

第493行代码:

$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";

php版本估计是5.5以上了,preg_replace的修饰符e已经不能用了;
如果要调整可以用preg_replace_callback或者其他函数调整:

$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n";
修改成
$out =  "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/", function($r) { return stripslashes(trim($r[1],'\'')); }, var_export($t, true)). ";\n";

*lib_main.php 提示错误

$ext = end(explode('.', $tmp));

改为:

$arr_a = explode('.', $tmp);

    $ext = end($arr_a);

ecshop运行的一个问题。急!  5

ecshop电子商城开源软件,安装好后进入首页的时候报这样1个警告是什么原因啊?如何解决? Warning: preg_replace_callback(): Modifier /e cannot be used with replacement callback in D:\myweb\www\ecshop\includes\cls_template.php on line 1072 相关代...   展开
相关代码更正如下:
if ($file_type == '.dwt')
        {
            /* 将模板中所有library替换为链接 */
            $pattern     = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/e';
			$replacement = function ($r) { return '{include file='.strtolower($r[1]). '}';};
			$source      = preg_replace_callback($pattern, $replacement, $source);
数据库备份时出错 Strict Standards: Non-static method cls_mysql::escape_string() should 
not be called statically /includes/cls_sql_dump.php on line 31

解决方法:


 
 
找到includes\cls_mysql  第370行
function escape_string($unescaped_string)
前面加一个 static
ecshop 问题一:商城首页报错 Strict Standards: Only variables should be passed by reference in D:\wamp\ecshop\includes\cls_template.php on line 422
 
 

找到提示错误的文件 cls_template.php 及行号

把 $tag_sel = array_shift(explode(' ', $tag)); 改成:

$tag_arr = explode(' ', $tag);  $tag_sel = array_shift($tag_arr);

并且删除 D:\wamp\www\ecshop\temp\caches下所有的文件

题二:后台首页报错

Strict Standards: Non-static method cls_image::gd_version() should not be called statically in D:\wamp\www\ecshop\includes\lib_base.php on line 346

找到D:\wamp\www\ecshop\includes\cls_image.php文件

搜索 function gd_version 改成 static function gd_version

问题三:后台-商店设置 

Strict Standards: mktime(): You should be using the time() function instead in D:\wamp\www\ecshop\admin\sms_url.php on line 31 Strict Standards: mktime(): You should be using the time() function instead in D:\wamp\www\ecshop\admin\shop_config.php on line 32

根据错误提示 把 mktime() 改成 time()

问题四:后台-起始页

Strict Standards: Redefining already defined c**tructor for class alipay in D:\www\es\includes\modules\payment\alipay.php on line 85

1)、错误原因: PHP 类,有两种构造函数,一种是跟类同名的函数,一种是 __contruct()。从PHP5.4开始,对这两个函数出现的顺序做了最严格的定义,必须是 __c**truct() 在前,同名函数在后 2)、 解决方法: 调换一下两个函数的前后位置即可。 以 includes/modules/payment/alipay.php  为例: 将下面这两个函数的位置互换一下就OK了,__contruct()在前,alipay()在后

3)、ECSHOP的很多类文件 都存在这个问题,都需要修改掉。

问题五:后台-数据备份 

 Strict standards: Redefining already defined constructor for class cls_sql_dump in D:\wamp\www\ecshop\admin\includes\cls_sql_dump.php on line 90 Strict standards: Non-static method cls_sql_dump::get_random_name() should not be called statically in D:\wamp\www\ecshop\admin\database.php on line 64

根据错误提示 把 cls_sql_dump的 function __construct()改到  function cls_sql_dump()的前面

把 cls_sql_dump的 function get_random_name()改成 static  function get_random_name() 问题六:

Deprecated: Assigning the return value of new by reference is deprecated in  \admin\sitemap.php on line 46

 $sm     =& new google_sitemap();

在5.3版本之后已经不允许在程序中使用”=&”符号。如果你的网站出现了Deprecated: Assigning the return value of new by reference is deprecated in 错误,别着急,先定位到出错的文件,查找下是不是在程序中使用了”=&”,例如刚才定位到网站程序中发现了下图的程序,发现使用了”=&”符号,去掉‘&’符号之后程序运行正常

问题七:

Declaration of phpbb::set_cookie() should be compatible with integrate::set_cookie...

解决办法:把function set_cookie ($username="") 改为function set_cookie ($username="", $remember = NULL)即可

问题八:

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in..

我遇见了有两处,都在cls_template.php文件中:

 1、return preg_replace("/{([^\}\{\n]*)}/e", "\$this->sel ect('\\1');", $source); 替换为 return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->sel ect($r[1]); }, $source); 2、$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);

 $val= preg_replace_callback("/\[([^\[\]]*)\]/eis",function($r){return str_replace('$','\$',$r[1]);}, $val);

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值