Home php教程 php手册 Strict Standards: Only variables should be passed by referen

Strict Standards: Only variables should be passed by referen

Jun 13, 2016 am 09:57 AM
only reference variables article

本文章来给大家介绍Strict Standards: Only variables should be passed by reference in解决办法,各位朋友可参考。

php中使用内置的reset函数可以获取array的第一个元素的值。例如:

 代码如下 复制代码

$arr = array('one', 'two', 'three');

echo reset($arr);  

// 输出的结果为 one对于下述代码,如果php开启了"Strict Standards",将会看到"Strict Standards: Only variables should be passed by reference in"的提示。

 代码如下 复制代码

$str = 'netingcn.com';

echo reset(explode('.', $str));

为什么会这样呢?可以先看看reset函数的定义:

function reset (array &$array) {}从定义中可以看到,reset接受的参数是一个array的引用。而上述代码中explode返回值不是任何array的引用,所以在"Strict Standards"下会有上述提示。解决办法很简单,只需要把reset(explode('.', $str))分两步写即可。第一步先把explode的返回值赋给一个变量,第二步把这个变量作为reset参数。

出现上面的提示的不只是reset函数,只要参数接受的是对象引用,而传值直接使用function返回值都会看到那样的提示。例如内置的array_pop、shuffle、curent、next、prev、next等等

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How can I make money by publishing articles on Toutiao today? How to earn more income by publishing articles on Toutiao today! How can I make money by publishing articles on Toutiao today? How to earn more income by publishing articles on Toutiao today! Mar 15, 2024 pm 04:13 PM

1. How can you make money by publishing articles on Toutiao today? How to earn more income by publishing articles on Toutiao today! 1. Activate basic rights and interests: original articles can earn profits by advertising, and videos must be original in horizontal screen mode to earn profits. 2. Activate the rights of 100 fans: if the number of fans reaches 100 fans or above, you can get profits from micro headlines, original Q&A creation and Q&A. 3. Insist on original works: Original works include articles, micro headlines, questions, etc., and are required to be more than 300 words. Please note that if illegally plagiarized works are published as original works, credit points will be deducted, and even any profits will be deducted. 4. Verticality: When writing articles in professional fields, you cannot write articles across fields at will. You will not get appropriate recommendations, you will not be able to achieve the professionalism and refinement of your work, and it will be difficult to attract fans and readers. 5. Activity: high activity,

Solution to PHP Notice: Only variables should be passed by reference in Solution to PHP Notice: Only variables should be passed by reference in Jun 22, 2023 pm 09:04 PM

PHP is a commonly used server-side scripting language, so when developing a website, PHPNotice error messages are very common. Among them, "PHPNotice:Onlyvariablesshouldbepassedbyreferencein" is a common error message. What this error message means is: only variables should be passed by reference. We know that in a function or method, variables can be called by passing parameters, so that in the code

How to add article in HTML5? How to add article in HTML5? Sep 12, 2023 am 11:37 AM

In this article, we will learn how to add articles in HTML5. One of the new segmentation elements in HTML5 is the tag. Articles are represented in HTML using tags. More specifically, the content contained within the element is different from the rest of the site's content (even though they may be related). Let us consider the following example to understand how to add an article in HTML5 Example 1 In the following example, we are using inline styles in the article element. <!DOCTYPEhtml><html><body><articlestyle="width:300px;border:2pxsolidgray;padding:

Interpretation of Vitalik's new article: Why does Rollup, whose blob space is not used efficiently, fall into development difficulties? Interpretation of Vitalik's new article: Why does Rollup, whose blob space is not used efficiently, fall into development difficulties? Apr 01, 2024 pm 08:16 PM

How to understand @VitalikButerin’s new article’s thoughts on Ethereum’s expansion? Some people say that Vitalik’s order for Blob Inscription is outrageous. So how do blob packets work? Why is the blob space not being used efficiently after the upgrade in Cancun? DAS data availability sampling in preparation for sharding? In my opinion, the performance of Cancun is usable after the upgrade, and Vitalik is worried about the development of Rollup. Why? Next, let me talk about my understanding: As I have explained many times before, Blob is a temporary data package that is decoupled from EVM calldata and can be directly called by the consensus layer. The direct benefit is that EVM does not need to access the Blob when executing transactions. data, thus resulting in lower execution layer computations

Detailed method for sending articles and recordings at the same time via WeChat Detailed method for sending articles and recordings at the same time via WeChat Mar 26, 2024 am 09:16 AM

1. Open your phone, click on the WeChat software, and enter the WeChat home page settings. 2. Find [My] in the lower right corner of WeChat, open it, and enter the [My] page. 3. Click Collection and then open a new page.

What should I do if the content of Dreamweaver CMS articles disappears? Quick solution What should I do if the content of Dreamweaver CMS articles disappears? Quick solution Mar 29, 2024 am 11:36 AM

DedeCMS is a powerful open source content management system that is widely used in various website construction. However, sometimes article content may disappear during use, which causes trouble to website operators. This article will introduce to you the common reasons and quick solutions for the disappearance of article content in DreamWeaver CMS, and provide specific code examples, hoping to help you solve this problem. 1. Possible reasons for the disappearance of article content: database operation error: the table storing article content in the database may

Is the content of DreamWeaver CMS articles lost? Done in one move Is the content of DreamWeaver CMS articles lost? Done in one move Mar 29, 2024 am 09:06 AM

DedeCMS is a powerful open source website content management system that is deeply loved by the majority of website builders. However, during use, article content may sometimes be lost, which causes considerable trouble to website administrators. This article will introduce a method to solve the problem of missing article content in DreamWeaver CMS, and provide specific code examples, hoping to help website administrators who encounter this problem. Description of the problem: In the process of using Dreamweaver CMS, sometimes the content of articles is lost. possible

Is it profitable to publish articles on Toutiao Search Express Edition? Is it profitable to publish articles on Toutiao Search Express Edition? Feb 29, 2024 pm 04:16 PM

Toutiao Search Express software not only provides a wealth of article content for users to browse, but also provides a platform for users to express themselves and share knowledge. Many users would like to know whether publishing articles in Toutiao Search Express Edition can make money, so today the editor of this site will introduce in detail whether publishing articles in Toutiao Search Express Edition can make money and how to publish articles. I hope it can help everyone in need. Is there any profit from publishing articles on Toutiao Search Express? Answer: Yes. 1. First, we open the Toutiao search speed version software. On the homepage, we click the [plus icon] in the upper right corner; 2. Then we will come to the page for publishing articles, where we can upload videos, photos, links, and enter text. Wait, everything is set up

See all articles