<?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. angular+bootstrap+MVC 之三,分页控件初级版

    今天实现一个分页控件,效果如下: 1.HTML: <!doctype html> <!--suppress ALL --> <html ng-app="appT ...

  2. Ubuntu 16.10 在 VMware 上无法安装的解决办法

    参考:http://askubuntu.com/questions/840822/ubuntu-16-10-doesnt-work-in-virtual-machine-vmware 1- Edit ...

  3. 解决Linux性能问题的前60秒

    为了解决性能问题,你登入了一台Linux服务器,在最开始的一分钟内需要查看什么? 在Netflix我们有一个庞大的EC2 Linux集群,还有非常多的性能分析工具来监控和调查它的性能.其中包括用于云监 ...

  4. python学习-day16:函数作用域、匿名函数、函数式编程、map、filter、reduce函数、内置函数r

    一.作用域 作用域在定义函数时就已经固定住了,不会随着调用位置的改变而改变 二.匿名函数 lambda:正常和其他函数进行配合使用.正常无需把匿名函数赋值给一个变量. f=lambda x:x*x p ...

  5. 使用-MM生成include指令和依赖生成(make include directive and dependency generation with -MM)

    I want a build rule to be triggered by an include directive if the target of the include is out of d ...

  6. 【学】CSS3基础实例1 - 用CSS3做网页中的小三角,以及transition的用法

    自开了博客园已经有2周了吧,虽然转载了一些觉得比较有用的文章之外还没有开始写自己的一些学习记录,那就从今天开始. 目前看了妙味的不少视频,有css+html,js的基础和中级也都看完了,作业也都做了, ...

  7. winform中DataGrid控件的宽度设置

    最近修改一个win5.0的PDA程式,碰到一个问题.就是给DataGrid控件绑定数据的时候,这个控件的宽度不能调整,有时候数据较长,就显示不全.然后想在程式里自定义它的宽度,设置不成功.然后网上没找 ...

  8. (转)创建Graphics的三种方法

    方法一.利用控件或窗体的Paint事件中的PainEventArgs 在窗体或控件的Paint事件中接收对图形对象的引用,作为PaintEventArgs(PaintEventArgs指定绘制控件所用 ...

  9. springboot + swagger

    swagger用于定义API文档. 好处: 前后端分离开发 API文档非常明确 测试的时候不需要再使用URL输入浏览器的方式来访问Controller 传统的输入URL的测试方式对于post请求的传参 ...

  10. [vB.NET]为控件添加鼠标悬浮时的提示气泡

    实例代码: Dim k As ToolTip k = New ToolTip() k.AutoPopDelay = '显示出气泡后的延时时间(毫秒) k.InitialDelay = '出现前的延时( ...