Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
Product introduction
ECShop is a B2C independent online store system under Shanghai ShopEx, which is suitable for enterprises and individuals to quickly build personalized online stores. The system is a cross-platform open source program developed based on PHP language and MYSQL database architecture.
ECShop carefully listens to the needs and suggestions of every merchant. It not only designs a humanized online store management system to help merchants get started quickly, but also improves the shopping process according to the shopping habits of Chinese people to achieve a better user shopping experience.
ECShop online system in product function, stability, execution efficiency, load capacity, security and SEO support (search engine optimization) and other aspects are in the leading position of similar domestic products, become one of the most popular shopping systems in China.
Deploy ECSHOP
1. Deploy the ecshop project in the apache project default path /htdocs/ directory, decompress and grant chmod -r 777 ecshop;
2, http://ipadr:port/ecshop check the installation of ecShop environment, mysql or GD or JPEG will not support;
Install /includes/lib_installer.php
Mysql. ini extension=mysql.so; mysql. ini extension=mysql.so;
5. After the installation and deployment of mysql, Apache, PHP and other environments, after the restart, when the project is opened, there is no unsupported system environment;
date_default_timezone_set ('Asia/Shanghai');
6, installation of gd_version() static use method; And preg_replace(): the method is no longer used;
$p = new cls_image();
return $p->gd_version();
return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return$this->select($r[1]); }, $source);
Copy the code
7. We will continue to encounter the preg_replace() method of the cls_template.php page;
7. The preg_replace() method needs to be replaced with preg_replace_callback().
$out = "<? php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));" , var_export($t, true)) . "; \n";Copy the code
replace
$out = "<? php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" , function($r) {return stripslashes(trim($r[1],'\'')); }, var_export($t, true)) . "; \n";Copy the code
Error like this:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in D:\wyh\ecshop\includes\cls_template.php on line 300
Copy the code
To solve the problem
1. Error causes:
The /e modifier used in preg_replace() is deprecated in PHP5.5.x.
If your PHP version happens to be PHP5.5.x, your ECSHOP will definitely report an error like this.
2. Solutions:
Cls_template.php on line 288
return preg_replace(“/{([^}{\n]*)}/e”, “$this->select(‘\1’);” , source); return preg_replace(“/{([^\}\{\n]*)}/e”, “\this->select(‘\1’);” , $source);
Replaced by:
return preg_replace_callback(“/{([^}{\n]*)}/”, function(r) { return this->select(r[1]); }, source);
Cls_template.php on line 493
$out = "<? php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));" , var_export($t, true)) . "; \n"; $out = "<? php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));" , var_export($t, true)) . "; \n";Copy the code
Replaced by:
$out = "<? php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" , function($r) {return stripslashes(trim($r[1],'\'')); }, var_export($t, true)) . "; \n";Copy the code
Cls_template.php on line 552
$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val);
Copy the code
Switch to
$val = preg_replace_callback("/\[([^\[\]]*)\]/", function($r) {return '.'.str_replace('$','$',$r[1]); }, $val);Copy the code
Cls_template.php on line 1069
$pattern = '/<! --\s#BeginLibraryItem\s\"\/(.*?) \"\s-->.*? <! --\s#EndLibraryItem\s-->/se'; $replacement = "'{include file='.strtolower('\\1'). '}'"; $source = preg_replace($pattern, $replacement, $source); $source = preg_replace($pattern, $replacement, $source);Copy the code
Switch to
$pattern = '/<! --\s#BeginLibraryItem\s\"\/(.*?) \"\s-->.*? <! --\s#EndLibraryItem\s-->/s'; $source = preg_replace_callback($pattern, function($r){return '{include file='.strtolower($r[1]). '}'; }, $source);Copy the code