[Reprint] ECshop and PHP 5.6 problem

Question 1:     

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

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

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in \upload\includes\cls_template.php on line 557

Error reason:

The above problem is that the modifier /e used in the preg_replace() function has been deprecated in PHP5.5.x. The preg_replace function was replaced with the preg_replace_callback function in PHP 5.5 and above.

Solution:

The solution to the problem is to replace all the parts of the code that use the preg_replace function with the preg_replace_callback function, and delete an obsolete /e modifier. 

example: 

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

replace with

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

Introduction to the preg_replace function http://php.net/manual/en/function.preg-replace.php

Introduction to preg_replace_callback function http://php.net/manual/en/function.preg-replace-callback.php

Question 2:

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

Strict Standards: Only variables should be passed by reference in D:\xampp\htdocs\ecshop\upload\includes\cls_template.php on line 424

Error reason:

The reason for this problem seems to be that in php5.4 array_shift can only be a variable, not a function return value.

The Chinese meaning is: "The incoming variable can only be a reference variable". The parameters of the array_shift function are passed by reference. By default, only specific variables can be passed in php5.3 and above, but not through the return value of the function.

Solution:

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

replace with

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

Then delete the temp folder in the project directory , copy the original temp folder again, and then visit the home page, you will find that everything is normal!

Question 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

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

Error reason:

As suggested in the question, because gd_version() in cls_image.php is not a static function, the above problem occurs when it is called in lib_base.php and lib_installer.php.

Solution:

Solution 1:     First, in the lib_image.php file, use Shift+F to search for the gd_version function. Then add the static modifier before the gd_version method, and this function becomes a static function.

Solution 2: Find the cls_image::gd_version() part in the lib_base.php and lib_installer.php functions, then create cls_image instances respectively, and then use the created instances to call the gd_version() function.

                      $cls_gile = new cls_image();

                      return $cls_gile->gd_version();

Question 4:

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

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

Error reason:

PHP5.3+ abolished the "=&" symbol, and used "=" for object copying

After version 5.3, the "=&" symbol is not allowed in the program. If the error Deprecated: Assigning the return value of new by reference is deprecated in appears on your website, don't worry, locate the wrong file first, and find out if "=&" is used in the program, for example, the cat just now Navigate to the website program and find the program shown in the figure below. It is found that the "=& amp;" symbol is used. After removing the '&' symbol, the program runs normally.

Solution:

Search all PHP files, replace '=&' with '='

Question 5:

Strict Standards: mktime(): You should be using the time() function instead in ......\admin\shop_config.php on line 32(后台商店设置) 

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

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

Error reason:

The meaning of this error message: When the mktime() method is called without parameters, an error message will be thrown. After PHP 5.1, calling mktime() without parameters will pop up a notification that violates the standard. If you want to call mktime without arguments, it is equivalent to calling time(), and it should be used instead.

Solution:

$auth = mktime();

Replace mktime() with time() method, the code is:

$auth = time();

Question 6:

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

Error reason:

The reason is related to the constructor in the PHP class. The early version of PHP used the function with the same name as the class as the constructor, and later appeared to use __construct() as the constructor.

Both functions can exist at the same time. In the PHP5.4 version, there are strict requirements on the order of these two functions in the code. Under the PHP5.4 version, __construct() must be before,

The function of the same name is after, otherwise the above error message will appear.

Solution:

Just put the __construct() function above the function of the same name.

Question 7:

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

\includes\modules\integrates\ucenter.php......

If the method name of the subclass is the same as the method name of the superclass, the parameter list of the subclass should also be the same as that of the superclass.

Error problem:

vbb inherits the integrate class and rewrites the set_cookie() function, but the parameters of the vbb rewrite set_cookie function do not match the parameters of the parent class set_cookie, so the above problem occurs.

The function of the subclass has the same name as the parent class, and the function parameters of the subclass must be the same as the corresponding function parameters of the parent class.
According to the error prompt, modify, for example:

Solution:

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

If a similar error occurs, it can be solved in the same way.

Question 8:

Strict Standards: Redefining already defined constructor for class paypal

Error reason:

A PHP class has two constructors, one is a function with the same name as the class, and the other is ____construct(). Starting from PHP 5.4, the order in which these two functions appear is the most strictly defined, which must be ____construct() before, and the function of the same name after

Solution:

For example:
function __construct()  

   {

        $this->paypal();
    }
   
    function paypal()
    {
    }

Question 9:

After the ecshop 2.7.3 gbk version is installed under php5.4, the category name text does not display the problem

htmlspecialchars() has changed the default value of the third parameter string encoding to UTF-8 since php5.4.0, and the Chinese encoding of ecshop2.7.3 gbk version is GB2312 encoding, which is inconsistent with the current default parameters, resulting in all htmlspecialchars () processed characters cannot be displayed.
Solution:
$str_converted = htmlspecialchars($str, ENT_COMPAT ,'GB2312');
It is recommended not to install gbk encoding ecshop under php5.4.

Question 10:

The verification code in the background of the website does not display PHP Strict Standards: Redefining already defined constructor for class captcha in D:\web\322\includes\cls_captcha.php on line 119

Open includes/cls_captcha.php  

 
find the code below
   function __construct($folder = '', $width = 145, $height = 20)
    {
        $this->captcha($folder, $width, $height);
    }
move it to

The top of the function captcha($folder = '', $width = 145, $height = 20).

 

 

The information is organized by uuecshop. For more articles, please log in to http://www.uuecs.com. Please indicate when reprinting.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324642369&siteId=291194637
5.6