简体   繁体   中英

Strict Standards :Only variables should be passed by reference is

Strict Standards: Only variables should be passed by reference in /home/zumpu/public_html/cats/cats-0.8.0/lib/DataGrid.php on line 1519

Strict Standards: Only variables should be passed by reference in /home/zumpu/public_html/cats/cats-0.8.0/lib/DataGrid.php on line 1535

if ($sizable)
            {
                $formatString = '<th align="left" class="resizeableCell" '
                    . 'style="width:5px; border-collapse: collapse; '
                    . '-moz-user-select: none; -khtml-user-select: none;';

               if (end(array_keys($this->_currentColumns)) != $index) //line 1519
               {
                   //Uncomment for gray resize bars
                   $formatString .= 'border-right:1px solid gray;';
               }

                $formatString .=
                      'user-select: none;" onmouseover="style.cursor = '
                    . '\'e-resize\'" onmousedown="startResize(\'cell%s%s\', '
                    . '\'table%s\', \'cell%s%s\', %s, \'%s\', \'%s\', '
                    . '\'%s\', \'%s\', this.offsetWidth);">';

                echo sprintf(
                    $formatString,
                    $md5InstanceName, $index,
                    $md5InstanceName,
                    $md5InstanceName, end(array_keys($this->_currentColumns)),// line 1535
                    $this->_tableWidth,
                    urlencode($this->_instanceName),
                    $_SESSION['CATS']->getCookie(),
                    $data['name'],
                    implode(',', $cellIndexes)
                );

                echo '<div class="dataGridResizeAreaInnerDiv"></div></th>', "\n";
            }
        }

help me out ia stuck for 2 days

Strictly speaking you're not supposed to pass the return value of a function directly to another function that takes its arguments as a reference without first assigning it to a named variable.

It usually works anyway, and probably won't break, [until a PHP version change breaks it] but because of those reasons it generates an E_STRICT message.

This should remove the message, but preserve the current functionality:

            $keys = array_keys($this->_currentColumns);

            if (end($keys)) != $index) //line 1519

            /* ... */

            echo sprintf(
                $formatString,
                $md5InstanceName, $index,
                $md5InstanceName,
                $md5InstanceName, end($keys),// line 1535
                $this->_tableWidth,
                urlencode($this->_instanceName),
                $_SESSION['CATS']->getCookie(),
                $data['name'],
                implode(',', $cellIndexes)
            );

Try -

$keys = array_keys($this->_currentColumns);
if (end($keys) != $index){

and

$md5InstanceName, end($keys),

from the docs http://php.net/end -
end ( array &$array ) -> The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference. The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference. Must pass a variable to end() , not a function, ie. array_keys() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM