简体   繁体   English

严格标准:仅变量应通过引用 PHP 5.4 分配

[英]Strict Standards: Only variables should be assigned by reference PHP 5.4

I upgraded my PHP version to 5.4 ( XAMPP 1.7.3 to 1.8.0).我将 PHP 版本升级到 5.4( XAMPP 1.7.3 到 1.8.0)。 Now I see Strict Standards error, for myDBconnection :现在我看到了myDBconnection严格标准错误:

Strict Standards: Only variables should be assigned by reference in C:\\xampp\\htdocs\\alous\\include\\dbconn.php on line 4严格标准:在 C:\\xampp\\htdocs\\alous\\include\\dbconn.php 第 4 行中,应仅通过引用分配变量

dbconn.php: dbconn.php:

<?php
    defined('_VALID') or die('Restricted Access!');

    $conn = &ADONewConnection($config['db_type']); // <--- This Line 4

    if ( !$conn->Connect($config['db_host'],
                         $config['db_user'],
                         $config['db_pass'],
                         $config['db_name'])) {

        echo 'Could not connect to MySQL! Please check your database settings!';
        die();
    }
    $conn->execute("SET NAMES 'utf8'");
?>

Note: I don't need to disable Strict Standards in php.ini with this method error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT !注意:我不需要使用这种方法error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT在 php.ini 中禁用严格标准! I want to fix my PHP code.我想修复我的 PHP 代码。

You should remove the & (ampersand) symbol, so that line 4 will look like this:您应该删除&& )符号,以便第 4 行如下所示:

$conn = ADONewConnection($config['db_type']);

This is because ADONewConnection already returns an object by reference.这是因为 ADONewConnection 已经通过引用返回了一个对象。 As per documentation , assigning the result of a reference to object by reference results in an E_DEPRECATED message as of PHP 5.3.0根据文档,从 PHP 5.3.0 开始,通过引用将引用的结果分配给对象会产生 E_DEPRECATED 消息。

It's because you're trying to assign an object by reference.这是因为您试图通过引用分配对象。 Remove the ampersand and your script should work as intended.删除&符号,您的脚本应该按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 严格的标准:ADONewConnection中只能通过引用分配变量 - Strict Standards: Only variables should be assigned by reference in ADONewConnection 严格的标准:只能通过引用传递变量PHP购物车 - Strict Standards: Only variables should be passed by reference PHP Shopping Cart 严格标准:只应通过引用传递变量 - php错误 - Strict Standards: Only variables should be passed by reference - php error 烦人的PHP错误:“严格的标准:只有变量应该通过引用传递” - Annoying PHP error: “Strict Standards: Only variables should be passed by reference in” 严格标准:只应在functions.php中通过引用传递变量 - Strict Standards: Only variables should be passed by reference in functions.php PHP严格标准:在wordpress函数中,只能通过引用传递变量 - PHP Strict Standards: Only variables should be passed by reference in on wordpress function PHP 严格标准:在 .lib 中只应通过引用传递变量 - PHP Strict Standards: Only variables should be passed by reference in .lib PHP严格标准:只有变量应通过引用传递给 - PHP Strict Standards: Only variables should be passed by reference in 面向PHP对象的“严格标准:仅变量应通过引用传递给” - PHP Object Oriented “Strict standards: Only variables should be passed by reference in” 严格标准:只有变量应通过引用传递给 - Strict Standards: Only variables should be passed by reference in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM