Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 大侠求助,php报错,在线等。。。。。。

大侠求助,php报错,在线等。。。。。。

Jun 23, 2016 pm 02:16 PM

each PHP

错误信息

Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of each(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in D:\APMServ5.2.6\www\htdocs\base\admin\config.php on line 23

Parse error: syntax error, unexpected '[' in D:\APMServ5.2.6\www\htdocs\base\admin\config.php on line 23

错误位置代码
if ( $step == "modify" ){    $var = $_POST['var'];    do    {        $val = each( &$var )[1];//报错        $key = each( &$var )[0];//报错        if ( each( &$var ) )        {            $msql->query( "update {P}_base_config set value='{$val}' where variable='{$key}'" );        }    } while ( 1 );    sayok( $strConfigOk, "config.php", "" );}
Copy after login

回复讨论(解决方案)

为什么要这样写呢?
$val = each( &$var )[1];
$key = each( &$var )[0];
这样不行吗?
$val = each( $var )[1];
$key = each( $var )[0];

写作这样不是更好?
list($key, $val) = each( $var );

为什么要这样写呢?
$val = each( &$var )[1];
$key = each( &$var )[0];
这样不行吗?
$val = each( $var )[1];
$key = each( $var )[0];

写作这样不是更好?
list($key, $val) = each( $var ); 一这样环境就卡死了

没道理的!
你不能因为你的程序有问题就乱改一气

each( &$var ) 出错的原因是不能这样传递引用,这是 php 5.3 才有的约定
而 each( $var )[0] 这样的写法是 php 5.3 才有的

如果同时遵守 php 5.3 的语法规则就卡死,那你就要想想你的问题出在哪里了

没道理的!
你不能因为你的程序有问题就乱改一气

each( &$var ) 出错的原因是不能这样传递引用,这是 php 5.3 才有的约定
而 each( $var )[0] 这样的写法是 php 5.3 才有的

如果同时遵守 php 5.3 的语法规则就卡死,那你就要想想你的问题出在哪里了 哦,我的生产环境是php5.2.6的,这个按照list($key, $val) = each( $var );这样改就卡死了

do while(1) 无限循环没有退出的语句,为何会不卡?

那你 print_r($_POST['var']); 贴出结果

do while(1) 无限循环没有退出的语句,为何会不卡? 大侠求助,刚入门 如何退出

if ( each( &$var ) )
        {
            $msql->query( "update {P}_base_config set value='{$val}' where variable='{$key}'" );
break;
        }
这样就能退出了

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)

Solve PHP error: The specified namespace class was not found Solve PHP error: The specified namespace class was not found Aug 18, 2023 pm 11:28 PM

Solve PHP error: The specified namespace class was not found. When developing using PHP, we often encounter various error messages. One of the common errors is "The specified namespace class was not found". This error is usually caused by the imported class file not being properly namespace referenced. This article explains how to solve this problem and provides some code examples. First, let’s take a look at an example of a common error message: Fatalerror:UncaughtError:C

Solve PHP error: problems encountered when inheriting parent class Solve PHP error: problems encountered when inheriting parent class Aug 17, 2023 pm 01:33 PM

Solving PHP errors: Problems encountered when inheriting parent classes In PHP, inheritance is an important feature of object-oriented programming. Through inheritance, we can reuse existing code and extend and improve it without modifying the original code. Although inheritance is widely used in development, sometimes you may encounter some error problems when inheriting from a parent class. This article will focus on solving common problems encountered when inheriting from a parent class and provide corresponding code examples. Question 1: The parent class is not found. During the process of inheriting the parent class, if the system does not

How to deal with PHP error: Call to undefined function? How to deal with PHP error: Call to undefined function? Jul 12, 2023 am 10:18 AM

How to deal with PHP error: Calltoundefinedfunction problem? During the development process using PHP, various errors are often encountered. One of the common errors is "Calltoundefinedfunction", which means that an undefined function was called. This kind of error may cause the code to fail and cause trouble to developers. This article explains how to handle this error and provides some code examples. Check whether the function is correct

PHP error: What should I do if I call a function in an undefined namespace? PHP error: What should I do if I call a function in an undefined namespace? Aug 17, 2023 am 11:25 AM

PHP error: What should I do if I call a function in an undefined namespace? When programming in PHP, we often encounter errors when calling functions in undefined namespaces. This error usually occurs when we reference a namespace but don't import it correctly. This article will introduce you to several ways to solve this problem and provide corresponding code examples. The first solution is to use a namespace prefix to call the function. When we reference a namespace but do not import functions in that namespace, we

PHP error: Undefined constant solution! PHP error: Undefined constant solution! Aug 17, 2023 pm 02:52 PM

PHP error: Undefined constant solution! In PHP programming, we often encounter constant undefined errors. This error usually occurs when undefined constants are used in the code. This article will introduce the concept of constants and how to solve the problem of undefined constants. First, let's understand what constants are. In PHP, a constant is a value that once defined cannot be changed again. Constants are defined using the define() function. Here's a simple example: <?phpdefine("

How to quickly locate the line of code where PHP errors are reported? How to quickly locate the line of code where PHP errors are reported? Jul 14, 2023 am 09:34 AM

How to quickly locate the line of code where PHP errors are reported? When developing PHP projects, you often encounter various error reports. These error reports are very important for locating and solving problems. However, sometimes the error message is not detailed enough. It will only tell you the file and line number of the error, but no specific error message. This brings certain difficulties to us in locating and solving problems. This article will introduce some methods to help us quickly locate the specific line of code where PHP errors are reported. Enabling Error Reporting First, we need to make sure error reporting is enabled. In the PHP code, there is a

How to solve PHP error: syntax error, invalid constructor? How to solve PHP error: syntax error, invalid constructor? Aug 26, 2023 pm 09:45 PM

How to solve PHP error: syntax error, invalid constructor? Introduction: PHP is a very popular server-side scripting language. However, it is inevitable to encounter various errors when writing PHP code. One of the common errors is "Syntax error, invalid constructor". This article will explain the cause of this error and provide some solutions and sample code. Reason for the error: When we use constructors in PHP, there are some rules that must be followed. If we use invalid syntax in the constructor when creating an object, it will cause an error

Solve the problem of PHP error: invalid class constant Solve the problem of PHP error: invalid class constant Aug 19, 2023 pm 01:04 PM

Solving the problem of PHP error: Invalid class constant In PHP development, we often encounter the following error message: Fatalerror: Undefinedclassconstant'CONSTANT_NAME'in/path/to/file.phponline10 This kind of error message indicates that it is used in the code An invalid class constant name was obtained. Solving this problem is actually not difficult. Below I will introduce several possibilities in detail.

See all articles