ecshop安装报错处理过程

最近在学php可是安装ECShop的时候出现了好多问题,主要是我的php版本太高导致的,好像php5.3以上都会出现问题,然后就搜了好多教程怎么改错误,,耗费了我一上午的时间整理这个错误,气死人了,耽误我学习进度,所以有必要写篇文章纪念一下,
一、include/cls_template.php
1、找到
tagsel=arrayshift(explode(′′, t a g s e l = a r r a y s h i f t ( e x p l o d e ( ″ , tag));
改为
tagarr=explode(′′, t a g a r r = e x p l o d e ( ″ , tag);
tagsel=arrayshift( t a g s e l = a r r a y s h i f t ( tag_arr);

2、 找到
return preg_replace(“/{([^}{\n]*)}/e”, “$this->select(‘\1’);”, source);  
改为  
return preg_replace_callback(“/{([^}{\n]*)}/”, function(
source);  改为  return preg_replace_callback(“/{([^}{\n]*)}/”, function(
r) { return this>select( t h i s − > s e l e c t ( r[1]);}, $source);

3、找到
out="<?php\n". o u t ="< ? p h p \n " . ′ k = ’ . preg_replace(“/(\’$[^,]+)/e" ,"stripslashes(trim('\\1','\''));", var_export( t,true)).;\n; t , t r u e ) ) . “ ; \n ” ; 改 为 out = k=.pregreplacecallback(/(\’$[,]+)/",function( k = ′ . p r e g r e p l a c e c a l l b a c k ( “ / ( \’ $ [ , ] + ) / " , f u n c t i o n ( r){return stripslashes(trim(r[1],'\''));}, var_export( r[1],'\''));}, var_export( t, true)) . “;\n”;

4、找到
val=pregreplace("/\[([\[\]])\]/eis","..strreplace( v a l = p r e g r e p l a c e ( " / \[ ( [ \[ \] ] ∗ ) \] / e i s " , " ′ . ′ . s t r r e p l a c e ( ′ ’,’$’,’\1’)”, val); v a l ) ; 改 为 val = preg_replace_callback("/

([\[ ( [ \[
]*)\]/", function( r)return..strreplace($,$,$r[1]);, r ) r e t u r n ‘ . ′ . s t r r e p l a c e ( ‘ $ ′ , ′ $ ′ , $ r [ 1 ] ) ; , val);

5,找到
pattern = ‘/\s#BeginLibraryItem\s\"\/(.*?)\"\s.*?\s#EndLibraryItem\s/se’; pattern = ‘/\s#BeginLibraryItem\s\"\/(.*?)\"\s.*?\s#EndLibraryItem\s/se’; replacement = “’{include file=’.strtolower(‘\1’). ‘}’”;
source=pregreplace( s o u r c e = p r e g r e p l a c e ( pattern, replacement, r e p l a c e m e n t , source);
改为
pattern = ‘/\s#BeginLibraryItem\s\"\/(.*?)\"\s.*?\s#EndLibraryItem\s/s’; pattern = ‘/\s#BeginLibraryItem\s\"\/(.*?)\"\s.*?\s#EndLibraryItem\s/s’; source = preg_replace_callback( pattern,function( p a t t e r n , f u n c t i o n ( r){return '{include file='.strtolower(r[1]). '}';}, r[1]). '}';}, source);

6、类似这样的报错:

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

(1)错误原因:preg_replace() 函数中用到的修饰符 /e 在 PHP5.5.x 中已经被弃用了。如果你的PHP版本恰好是PHP5.5.X,那你的ECSHOP肯定就会报类似这样的错误。

(2)解决办法:

A、将 cls_template.php的300行
return preg_replace(“/{([^}{\n]*)}/e”, “$this->select(‘\1’);”, source);  
改为  
return preg_replace_callback(“/{([^}{\n]*)}/”, function(
source);  改为  return preg_replace_callback(“/{([^}{\n]*)}/”, function(
r) { return this>select( t h i s − > s e l e c t ( r[1]); }, $source);

B、将 cls_template.php
out="<?php\n". o u t ="< ? p h p \n " . ′ k = ’ . preg_replace(“/(\’$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export( t,true)).;\n; t , t r u e ) ) . “ ; \n ” ; 改 为 out = k=.pregreplacecallback(/(\’$[,]+)/",function( k = ′ . p r e g r e p l a c e c a l l b a c k ( “ / ( \’ $ [ , ] + ) / " , f u n c t i o n ( r) {return stripslashes(trim(r[1],'\''));}, var_export( r[1],'\''));}, var_export( t, true)) . “;\n”;

C、将cls_template.php
val=pregreplace("/\[([\[\]])\]/eis","..strreplace( v a l = p r e g r e p l a c e ( " / \[ ( [ \[ \] ] ∗ ) \] / e i s " , " ′ . ′ . s t r r e p l a c e ( ′ ’,’$’,’\1’)”, val); v a l ) ; 改 为 val = preg_replace_callback("/

([\[ ( [ \[
]*)\]/", function( r)return..strreplace($,$,$r[1]);, r ) r e t u r n ‘ . ′ . s t r r e p l a c e ( ‘ $ ′ , ′ $ ′ , $ r [ 1 ] ) ; , val);

D、将cls_template.php
pattern = ‘/\s#BeginLibraryItem\s\"\/(.*?)\"\s.*?\s#EndLibraryItem\s/se’; pattern = ‘/\s#BeginLibraryItem\s\"\/(.*?)\"\s.*?\s#EndLibraryItem\s/se’; replacement = “’{include file=’.strtolower(‘\1’). ‘}’”;
source=pregreplace( s o u r c e = p r e g r e p l a c e ( pattern, replacement, r e p l a c e m e n t , source);
改为
pattern = ‘/\s#BeginLibraryItem\s\"\/(.*?)\"\s.*?\s#EndLibraryItem\s/s’; pattern = ‘/\s#BeginLibraryItem\s\"\/(.*?)\"\s.*?\s#EndLibraryItem\s/s’; source = preg_replace_callback( pattern,function( p a t t e r n , f u n c t i o n ( r){return '{include file='.strtolower(r[1]). '}';}, r[1]). '}';}, source);

二、include/lib_base.php

1、找到
return cls_image::gd_version();
改为
p=newclsimage();return p = n e w c l s i m a g e ( ) ; r e t u r n p->gd_version();

2、找到
function gd_version()
改为
static function gd_version()

三、admin/shop_config.php和sms_url.php

找到
auth=mktime(); a u t h = m k t i m e ( ) ; 改 为 auth = time();

四、上传LOGO和水印出现Strict Standards: Only variables should be passed by reference

后台admin/shop_config.php,将两处
ext=arraypop(explode(., e x t = a r r a y p o p ( e x p l o d e ( ′ . ′ , file[‘name’]));
改为
exttmp=explode(., e x t t m p = e x p l o d e ( ′ . ′ , file[‘name’]);
ext=arraypop( e x t = a r r a y p o p ( ext_tmp);

五、数据库备份出现edefining already defined constructor for class cls_sql_dump\admin\includes\cls_sql_dump.php on line 90


function __construct(& db, d b , max_size =0)
{
this>clssqldump( t h i s − > c l s s q l d u m p ( db, max_size);  
    }  
移到  
function cls_sql_dump(&
max_size);      }  移到  function cls_sql_dump(&
db, $max_size=0)
前面

七、出现Non-static method cls_sql_dump::get_random_name() admin\database.php on line 64

打开includes\cls_sql_dump.php 479行 ,将
function get_random_name()
修改为
static function get_random_name()

八、支付出错:Strict Standards: Redefining already defined constructor for class kuaiqian in /data/web/includes/modules/payment/kuaiqian.php on line 83 Strict Standards: Redefining already defined constructor for class cod in /data/web/includes/modules/payment/cod.php on line 82

解决办法,将所有的构造函数放到前面,如alipay.php

function __construct()
{
$this->alipay();
}
移到
function alipay()
{
}
前面

九、出现Non-static method cls_sql_dump::get_random_name() admin\database.php on line 64

打开includes\cls_sql_dump.php 479行
function get_random_name()
修改成
static function get_random_name()
完毕,
如果还有其他错误,再推荐几个错误修改的博客
一号文章
二号文章
我会把本次改好的分享出来上传到我的这个账号,供大家参考,可以省去很多麻烦,直接使用或者替换源文件就可以了。

你可能感兴趣的:(PHP)