虚位以待(AD)
虚位以待(AD)
首页 > CMS教程 > Ecshop > 修改部分ecshop代码让ecshop支持PHP5.5及以上版本

修改部分ecshop代码让ecshop支持PHP5.5及以上版本
类别:Ecshop   作者:码皇   来源:互联网   点击:

php版本已经更新到7 0了,使用php5 2 5 3的人越来越少,更多的人转向使用更高的php版本。可以通过修改部分ecshop代码让其支持PHP5 5及以上版本。1、Deprecated:Assigning the return value of new by reference is ,魔客吧

php版本已经更新到7.0了,使用php5.2/5.3的人越来越少,更多的人转向使用更高的php版本。可以通过修改部分ecshop代码让其支持PHP5.5及以上版本。

1、Deprecated:Assigning the return value of new by reference is deprecated in F:xampphtdocsecsphp5includeslib.debug.php on line 303

  1. $pa = &new Print_a_class;
  2. //修改为:
  3. $pa = new Print_a_class;

PHP5.3+废除了”=&”符号,对象复制用”=”即可,详细如下:
PHP5对象复制是采用引用的方式。
如果不采用引用方式,则需要在复制对象时加关键字 clone。
如果在复制的过程中,同时要变更某些属性,则增加函数_clone()。

2、Deprecated:preg_replace():The/e modifier is deprecated,use preg_replace_callback instead *

出现这个错误的原因是 preg_replace() 函数修饰符/e 在 PHP5.5.x 中已经被弃用了,若出现这个错误可以用 preg_replace_callback 进行代替。(一般的可以直接去掉 e 函数,但以下需要用preg_replace_callback代替)

2.1 includescls_template.php 文件中的 fetch_str()函数

  1. return preg_replace("/{([^}{n]*)}/", "$this->select('1');", $source);
  2. //修改为
  3. return preg_replace_callback("/{([^}{n]*)}/",
  4. function ($match){
  5. return $this->select($match[1]);
  6. }, $source);

2.2 includescls_template.php 文件中的 smarty_prefilter_preCompile()函数

  1. $replacement = "'{include file='.strtolower('1').}'";
  2. $source = preg_replace_callback($pattern, $replacement, $source);
  3. //修改为
  4. $source = preg_replace_callback($pattern, function($match){
  5. return '{include file="'.strtolower($match[1]).'"}';
  6. }, $source);

2.3 includescls_template.php 文件中的 get_val()函数

  1. $val = preg_replace("/[([^[]]*)]/eis", "'.'.str_replace('$','$','1')", $val);
  2. //修改为
  3. $val = preg_replace_callback("/[([^[]]*)]/is",function($match){
  4. return ".".str_replace('$','$',$match[1]);
  5. }, $val);

2.4 includescls_template.php 文件中的 select()函数

  1. //$out = "
  2. //修改为
  3. $out = "
  4. return stripslashes(trim($match[1],'''));
  5. }, var_export($t, true)) . ";n";

*">3、 Strict Standards:Only variables should be passed by reference in*

5.3以上默认只能传递具体的变量,而不能通过函数返回值。可做类似以下修改;

  1. //includeslib_main.php
  2. $ext = end(explode('.', $tmp));
  3. //修改为
  4. $ext_arr = explode('.', $tmp);
  5. $ext = end($ext_arr);
  1. //includescls_template.php on line 422
  2. $tag_sel = array_shift(explode(' ', $tag));
  3. //修改为
  4. $tag_arr = explode(' ', $tag);
  5. $tag_sel = array_shift($tag_arr);

4、Strict Standards:Non-static method cls_image::gd_version() should not be called statically

  1. //修改 cls_image 类
  2. function gd_version()
  3. //修改为
  4. static function gd_version()

5 Strict Standards:mktime():You should be using the time() function instead

直接用time 代替mktime即可。

PHP5.1版后调用mktime()不带参数,等同于调用time(),,应用其代替。

6 Strict Standards:Redefining already defined constructor for class

将同名构造函数放在__construct()之后。

PHP类,有两种构造函数,一种是跟类同名的函数,一种是__construct()。从PHP5.4开始,对这两个函数出现的顺序做了最严格的定义,必须是__construct()在前,同名函数在后。

涉及到的修改文件有

文件名 文件大小 最后修改时间 状态
admin/
被修改:5
cloud.php “8167 Bytes” 2016/2/3 20:56 被修改
privilege.php “25918 Bytes” 2014/12/12 11:14 被修改
shop_config.php “13702 Bytes” 2016/2/3 20:56 被修改
sms_url.php “1186 Bytes” 2016/2/3 20:56 被修改
sql.php “4634 Bytes” 2014/12/12 11:19 被修改
admin/includes/
被修改:1
cls_sql_dump.php “14094 Bytes” 2016/2/6 18:39 被修改
includes/
被修改:6
cls_captcha.php “8734 Bytes” 2016/2/3 20:59 被修改
cls_image.php “23083 Bytes” 2016/2/2 23:10 被修改
cls_mysql.php “27347 Bytes” 2016/2/6 18:40 被修改
cls_template.php “44542 Bytes” 2016/2/6 19:49 被修改
lib.debug.php “25893 Bytes” 2016/2/2 21:59 被修改
lib_main.php “67400 Bytes” 2016/2/2 22:52 被修改
includes/modules/payment/
被修改:15
alipay.php “6661 Bytes” 2016/2/6 18:10 被修改
balance.php “2146 Bytes” 2016/2/6 18:10 被修改
bank.php “2091 Bytes” 2016/2/6 18:10 被修改
cappay.php “12133 Bytes” 2016/2/6 18:10 被修改
chinabank.php “5521 Bytes” 2016/2/6 18:10 被修改
cod.php “2208 Bytes” 2016/2/6 18:10 被修改
epay.php “5708 Bytes” 2016/2/6 18:10 被修改
ips.php “5554 Bytes” 2016/2/6 18:11 被修改
kuaiqian.php “13153 Bytes” 2016/2/6 18:11 被修改
paypal.php “8200 Bytes” 2016/2/6 18:11 被修改
paypal_ec.php “8429 Bytes” 2016/2/6 18:11 被修改
post.php “2134 Bytes” 2016/2/6 18:11 被修改
shenzhou.php “15209 Bytes” 2016/2/6 18:11 被修改
tenpay.php “8425 Bytes” 2016/2/6 18:12 被修改
tenpayc2c.php “8679 Bytes” 2016/2/6 18:12 被修改

修改后

后台

ecshop 修改 兼容PHP5.5


首页效果

ecshop 修改 兼容PHP5.5 首页效果

相关热词搜索: 修改部分ecshop代码让ecshop支持PHP5 5及以