ecshop在php5.6下的错误。在5.3下是正常的。应该是PHP高版本函数变化了。
错误提示:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/wwwroot/www.ufeelwine.com/includes/cls_template.php on line 1061
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/wwwroot/www.ufeelwine.com/includes/cls_template.php on line 483
具体网页地址:
http://www.ufeelwine.com/supplier.php?suppId=7
第483行:
<code> $out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n"; $out .= 'echo $this->_echash . $k[\'name\'] . \'|\' . serialize($k) . $this->_echash;' . "\n?>"; </code>
第1061行:
<code> $pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se'; $replacement = "'{include file='.strtolower('\\1'). '}'"; $source = preg_replace($pattern, $replacement, $source);</code>
应该怎么改写呢?
回复内容:
ecshop在php5.6下的错误。在5.3下是正常的。应该是PHP高版本函数变化了。
错误提示:
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/wwwroot/www.ufeelwine.com/includes/cls_template.php on line 1061
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/wwwroot/www.ufeelwine.com/includes/cls_template.php on line 483
具体网页地址:
http://www.ufeelwine.com/supplier.php?suppId=7
第483行:
<code> $out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n"; $out .= 'echo $this->_echash . $k[\'name\'] . \'|\' . serialize($k) . $this->_echash;' . "\n?>"; </code>
第1061行:
<code> $pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se'; $replacement = "'{include file='.strtolower('\\1'). '}'"; $source = preg_replace($pattern, $replacement, $source);</code>
应该怎么改写呢?
//-- 原本
<code>return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source); </code>
//-- 修改成
<code>return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source); </code>
//-- 原本
<code>$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val); </code>
//-- 修改成
<code>$val = preg_replace_callback("/\[([^\[\]]*)\]/is", function($r) { return '.'.$r[1]; }, $val); </code>
//-- 原本
<code>$out = "<?php \n" . '$k = ' . preg_replace("/(\'\\$[^,]+)/e" , "stripslashes(trim('\\1','\''));", var_export($t, true)) . ";\n"; </code></code>
//-- 修改成
<code>$out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" , function($r) { return stripslashes(trim($r[1],'\'')); }, var_export($t, true)) . ";\n"; </code></code>
//--- 原本
<code>$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se'; $replacement = "'{include file='.strtolower('\\1'). '}'"; $source = preg_replace($pattern, $replacement, $source); </code>
//--- 修改成
<code>$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/s'; $replacement = function ($r) { return '{include file='.strtolower($r[1]). '}'; }; $source = preg_replace_callback($pattern, $replacement, $source);</code>
试试,没有环境没办法测试,根据提示信息改的
第483行:改成
<code>$out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/e" , function($r) { return stripslashes(trim('\\1','\'')); }, var_export($t, true)) . ";\n";</code></code>
第1061行:改成
<code>//$pattern = '/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se'; //$replacement = "'{include file='.strtolower('\\1'). '}'"; $source = preg_replace('/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se', function($r) { return '{include file='.strtolower('\\1'). '}';}, $source);</code>
提示很清楚了啊
把preg_replace换成preg_replace_callback
看看preg_replace_callback的用法就明白了
/* 1、e参数去掉 2、后面的\1换成回调的数组对应的元素 */ //483行 $out = "<?php \n" . '$k = ' . preg_replace_callback("/(\'\\$[^,]+)/" ,function($r) { return stripslashes(trim($r[1],'\'')); }, var_export($t, true)) . ";\n";

PHP在电子商务、内容管理系统和API开发中广泛应用。1)电子商务:用于购物车功能和支付处理。2)内容管理系统:用于动态内容生成和用户管理。3)API开发:用于RESTfulAPI开发和API安全性。通过性能优化和最佳实践,PHP应用的效率和可维护性得以提升。

PHP可以轻松创建互动网页内容。1)通过嵌入HTML动态生成内容,根据用户输入或数据库数据实时展示。2)处理表单提交并生成动态输出,确保使用htmlspecialchars防XSS。3)结合MySQL创建用户注册系统,使用password_hash和预处理语句增强安全性。掌握这些技巧将提升Web开发效率。

PHP和Python各有优势,选择依据项目需求。1.PHP适合web开发,尤其快速开发和维护网站。2.Python适用于数据科学、机器学习和人工智能,语法简洁,适合初学者。

PHP仍然具有活力,其在现代编程领域中依然占据重要地位。1)PHP的简单易学和强大社区支持使其在Web开发中广泛应用;2)其灵活性和稳定性使其在处理Web表单、数据库操作和文件处理等方面表现出色;3)PHP不断进化和优化,适用于初学者和经验丰富的开发者。

PHP在现代Web开发中仍然重要,尤其在内容管理和电子商务平台。1)PHP拥有丰富的生态系统和强大框架支持,如Laravel和Symfony。2)性能优化可通过OPcache和Nginx实现。3)PHP8.0引入JIT编译器,提升性能。4)云原生应用通过Docker和Kubernetes部署,提高灵活性和可扩展性。

PHP适合web开发,特别是在快速开发和处理动态内容方面表现出色,但不擅长数据科学和企业级应用。与Python相比,PHP在web开发中更具优势,但在数据科学领域不如Python;与Java相比,PHP在企业级应用中表现较差,但在web开发中更灵活;与JavaScript相比,PHP在后端开发中更简洁,但在前端开发中不如JavaScript。

PHP和Python各有优势,适合不同场景。1.PHP适用于web开发,提供内置web服务器和丰富函数库。2.Python适合数据科学和机器学习,语法简洁且有强大标准库。选择时应根据项目需求决定。

PHP是一种广泛应用于服务器端的脚本语言,特别适合web开发。1.PHP可以嵌入HTML,处理HTTP请求和响应,支持多种数据库。2.PHP用于生成动态网页内容,处理表单数据,访问数据库等,具有强大的社区支持和开源资源。3.PHP是解释型语言,执行过程包括词法分析、语法分析、编译和执行。4.PHP可以与MySQL结合用于用户注册系统等高级应用。5.调试PHP时,可使用error_reporting()和var_dump()等函数。6.优化PHP代码可通过缓存机制、优化数据库查询和使用内置函数。7


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

禅工作室 13.0.1
功能强大的PHP集成开发环境

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器