<?php
$tag="1 2 3 4 5 6 7";
$tag_sel = array_shift(explode(' ', $tag));
print_r($tag_sel);

报错:
Strict Standards: Only variables should be passed by reference in E:\work\phpcom\yinyong.php on line 3

关于引用传递(摘自手册)

可以将一个变量通过引用传递给函数,这样该函数就可以修改其参数的值。语法如下:

<?php
function foo (& $var )
{
$var ++;
}

$a = 5 ;
foo ( $a );
// $a is 6 here
?>

注意在函数调用时没有引用符号——只有函数定义中有。光是函数定义就足够使参数通过引用来正确传递了。在最近版本的 PHP 中如果把 & 用在 foo(&$a);中会得到一条警告说“Call-time pass-by-reference”已经过时了。

以下内容可以通过引用传递:

  • 变量,例如 foo($a)
  • New 语句,例如 foo(new foobar())
  • 从函数中返回的引用,例如:

    <?php
    function & bar ()
    {
    $a = 5 ;
    return $a ;
    }
    foo ( bar ());
    ?>

    详细解释见引用返回

任何其它表达式都不能通过引用传递,结果未定义。例如下面引用传递的例子是无效的:

<?php
function foo (& $var )
{
$var ++;
}
function bar () // Note the missing &
{
$a = 5 ;
return $a ;
}
foo ( bar ()); // 自 PHP 5.0.5 起导致致命错误,自 PHP 5.1.1 起导致严格模式错误
// 自 PHP 7.0 起导致 notice 信息
foo ( $a = 5 ) // 表达式,不是变量
foo ( 5 ) // 导致致命错误
?>

这些条件是 PHP 4.0.4 以及以后版本有的。

以上是手册内容,再看代码中用的函数:

array_shift — 将数组开头的单元移出数组

说明

mixed array_shift ( array &$array )注意:这里的参数$array需要是一个变量/new 语句/函数返回的引用,单纯的函数返回值不可以

array_shift()array 的第一个单元移出并作为结果返回,将 array 的长度减一并将所有其它单元向前移动一位。所有的数字键名将改为从零开始计数,文字键名将不变。

Note: 使用此函数后会重置( reset()array 指针。

Strict Standards: Only variables should be passed by reference的更多相关文章

  1. 已解决:Strict Standards: Only variables should be passed by reference in

    今天安装ecshop的时候最上面出现了一个错误提示:Strict Standards: Only variables should be passed by reference in F:\www.x ...

  2. ECShop出现Strict Standards: Only variables should be passed by reference in的解决方法

    今天安装ecshop的时候最上面出现了一个错误提示:Strict Standards: Only variables should be passed by reference in F:\www.x ...

  3. ECshop Strict Standards: Only variables should be passed by reference in解决办法

    本文章来给各位同学介绍关于ECshop Strict Standards: Only variables should be passed by reference in解决办法,希望此教程 对各位同 ...

  4. [php-error-report]PHP Strict Standards: Only variables should be passed by reference

    // 报错代码:PHP Strict Standards: Only variables should be passed by reference $arr_userInfo['im_nation_ ...

  5. 出现Strict Standards: Only variables should be passed by reference in的解决方法

    出现Strict Standards: Only variables should be passed by reference in的解决方法 代码报错: <br /><b> ...

  6. 解决Strict Standards: Only variables should be passed by reference

    这个错误发生在大家php调试程序用到一段代码里,那就是格式化显示出变量的函数functionrdump($arr)的第5行, 这段代码出自ecmall团队之手,但是ecmall已经很古董了,在php5 ...

  7. php报警:Strict Standards: Only variables should be passed by reference in

    错误原因 因为end函数的原因. end函数: mixed end    ( array &$array   ) 你可以看到end的参数是一个引用(reference),而你只能把一个变量的引 ...

  8. Ecshop提示Only variables should be passed by reference in错误

    Ecshop是个坑爹货,为什么tiandi会说它是个坑爹货呢,请看一下下面的官方的运行环境推荐: 服务器端运行环境推荐·php版本5.0以上5.3以下的版本(推荐使用5.2系列版本)·Mysql版本5 ...

  9. MagicZoom bug-Strict Standards: Only variables should be assigned by reference Error

    问题:zencart Strict standards: Only variables should be assigned by reference in  jscript_zen_magiczoo ...

随机推荐

  1. Python Mysql 篇

    Python 操作 Mysql 模块的安装 linux: yum install MySQL-python window: http://files.cnblogs.com/files/wupeiqi ...

  2. Delphi ActiveX Form的使用实例

    Delphi ActiveX Form的使用实例 By knityster 1. ActiveX控件简介 ActiveX控件也就是一般所说的OCX控件,它是ActiveX技术的一部分. ActiveX ...

  3. 伯克利包过滤(Berkeley Packet Filter,BPF)语言

    libpcap支持一种功能非常强大的过滤语言——“伯克利包过滤”语法.使用BPF过滤规则,你可以确定该获取和检查哪些流量,忽略哪些流量.BPF让你能够通过比较第2.3.4层协议中各个数据字段值的方法对 ...

  4. Redis 新特性---pipeline(管道)

    转载自http://weipengfei.blog.51cto.com/1511707/1215042 Redis本身是一个cs模式的tcp server, client可以通过一个socket连续发 ...

  5. (String) 压缩String

    e.g.  aaabbcccc    返回a3b2c4 public static String compressString(String str) { StringBuilder sb=new S ...

  6. winform画图闪烁问题

    问题:在winform程序的onpaint方法中画图, 连续画, 如鼠标移动时就要不断画图, 会闪烁. 解决方法:将要画图的部分放到一个自定义控件中, 自定义控件的onpaint方法里面画图, 然后再 ...

  7. 解决【win10管理员已阻止程序运行】问题时有感

    今天在安装loadrunner11的时候点击setup弹出以下报错 然后试了很多方法,从网上找了各种解决方案:修改UAC.修改本地组策略,均未解决ps:本人电脑是win10家庭中文版. 研究了半天未果 ...

  8. simulate windows touch input

    更多信息请参考页面http://social.technet.microsoft.com/wiki/contents/articles/6460.simulating-touch-input-in-w ...

  9. PL/SQL 查找1-100之间的素数

    --实现查找1-100之间的素数 declare v_no ; --标记是第几个素数 v_number number; --表示1-100之间的数 v_num number; begin .. loo ...

  10. jquery 选择器汇总

    jQueryAPI_1.7.1_CN.chm下载地址http://download.csdn.net/detail/zhai123_/6459563 jquery 选择器大体上可分为4 类: 1.基本 ...