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 ...
随机推荐
- UIButton的使用
使用UIButton时需要注意的是: 1.UIButton的创建有专门的类方法(buttonWithType:,UILabel没有): 2.UIButton常用的属性包括:frame.titile.t ...
- My WelcomeApplet
import java.applet.*; import java.awt.*; import java.awt.event.*; public class WelcomeApplet extends ...
- MapReduce、Hbase接口API实践
读取hdfs中文件并做处理,取出卡号,通过卡号连接hbase查询出对应客户号,写入redis,因为不用输出,所以不调用context.write方法,整个操作在一个map中便可完成 protected ...
- itextSharp 附pdf文件解析
一.PdfObject: pdf对象 ,有9种,对象是按照对象内涵来分的,如果按照对象的使用规则来说,对象又分为间接对象和直接对象.间接对象是PDF中最常用的对象,如前面对象集合里面的,所有对象都是间 ...
- loadrunner 联机跑负载 win server 2012 r2环境部署
下列为在实际loadrunner 联机跑负载 win server 2012 r2环境部署中进行的成功案例,遇到的问题和解决方法,仅作整理和记录,如转载请署名及原文地址. ps:欢迎加q群872584 ...
- c++操作符重载
一.类型转换操作符(type conversion operator)[1] 参考: [1]. C++类型转换操作符(type conversion operator): http://www.cpp ...
- mac java目录
/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home mac java的安装目录为 /Library/Java/JavaVir ...
- jQuery基础 -- 如何判断页面元素存在与否
在传统的Javascript里,当我们对某个页面元素进行某种操作前,最好先判断这个元素是否存在.原因是对一个不存在的元素进行操作是不允许的.例如: document.getElementById(&q ...
- 织梦(dedecms)系统常用全局变量调用标签及路径
{dede:global.cfg_memberurl/} 指的是会员中心 对应/member/目录 {dede:global.cfg_cmsurl/} 对应的是网站根目录/ {dede:global. ...
- ZC706以太网扩展板接口
端口 BANK-VADJ PIN NAME PIN_NAME RGMII0 rgmii_0_txc 10 AB14 LA15_N PHY_0_GTXCLK rgmii_0_rxc 10 AE13 LA ...