Strict Standards: Only variables should be passed by reference
<?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 — 将数组开头的单元移出数组
说明
&$array )注意:这里的参数$array需要是一个变量/new 语句/函数返回的引用,单纯的函数返回值不可以array_shift() 将 array 的第一个单元移出并作为结果返回,将 array 的长度减一并将所有其它单元向前移动一位。所有的数字键名将改为从零开始计数,文字键名将不变。
Strict Standards: Only variables should be passed by reference的更多相关文章
- 已解决:Strict Standards: Only variables should be passed by reference in
今天安装ecshop的时候最上面出现了一个错误提示:Strict Standards: Only variables should be passed by reference in F:\www.x ...
- 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 ...
- ECshop Strict Standards: Only variables should be passed by reference in解决办法
本文章来给各位同学介绍关于ECshop Strict Standards: Only variables should be passed by reference in解决办法,希望此教程 对各位同 ...
- [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_ ...
- 出现Strict Standards: Only variables should be passed by reference in的解决方法
出现Strict Standards: Only variables should be passed by reference in的解决方法 代码报错: <br /><b> ...
- 解决Strict Standards: Only variables should be passed by reference
这个错误发生在大家php调试程序用到一段代码里,那就是格式化显示出变量的函数functionrdump($arr)的第5行, 这段代码出自ecmall团队之手,但是ecmall已经很古董了,在php5 ...
- php报警:Strict Standards: Only variables should be passed by reference in
错误原因 因为end函数的原因. end函数: mixed end ( array &$array ) 你可以看到end的参数是一个引用(reference),而你只能把一个变量的引 ...
- Ecshop提示Only variables should be passed by reference in错误
Ecshop是个坑爹货,为什么tiandi会说它是个坑爹货呢,请看一下下面的官方的运行环境推荐: 服务器端运行环境推荐·php版本5.0以上5.3以下的版本(推荐使用5.2系列版本)·Mysql版本5 ...
- 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 ...
随机推荐
- !!!!!122. Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...
- Bootstrap整体架构
大多数Bootstrap的使用者都认为Bootstrap只是提供了CSS组件和JavaScript插件,其实CSS组件和JavaScript插件只是Bootstrap框架的表现形式而已,他们都是构建在 ...
- Vmware web client 5.5 控制台连接不上:Connection timed out
因XP下安装vsphere client5.5后,无法连接远程vsphere.因此使用vsphere web client. 但是用vsphere web client打开控制台,报错:Conneti ...
- Android开发60条技术经验总结
Android开发60条技术经验总结,以下是全文: 1. 全部Activity可继承自BaseActivity,便于统一风格与处理公共事件,构建对话框统一构建器的建立,万一需要整体变动,一处修改到处有 ...
- 图的存储,搜索,遍历,广度优先算法和深度优先算法,最小生成树-Java实现
1)用邻接矩阵方式进行图的存储.如果一个图有n个节点,则可以用n*n的二维数组来存储图中的各个节点关系. 对上面图中各个节点分别编号,ABCDEF分别设置为012345.那么AB AC AD 关系可以 ...
- UIUC同学Jia-Bin Huang收集的计算机视觉代码合集
转自:http://blog.sina.com.cn/s/blog_631a4cc40100wrvz.html UIUC的Jia-Bin Huang同学收集了很多计算机视觉方面的代码,链接如下: ...
- php数组转换成json格式。
{ "touser":"OPENID", "template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0t ...
- JS,Jquery获取各种屏幕的宽度和高度
Javascript: 网页可见区域宽: document.body.clientWidth网页可见区域高: document.body.clientHeight网页可见区域宽: document.b ...
- PHP时间日期
PHP常用的几个时间日期函数有:date(),mktime(),strtotime(); 一.string date ( string $format [, int $timestamp ] ) 函数 ...
- (Java和C++)二进制date数据写进android保存为yuv格式
Java实现函数: String strpath = "/storage/emulated/0/DCIM/" + i + "output.yuv"; bool ...