search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

Home Backend Development PHP PHP7 new features manual Parameter processing mechanism modification

Parameter processing mechanism modification

Collection 105
Read 69606
update time 2016-09-11

1. Duplicate parameter naming is no longer supported.

Duplicate parameter naming is no longer supported. For example, when the following code is executed, an error will be reported:

public function foo($a, $b, $unused, $unused) {
          // ...
}
Editor's note: No one should use it like this.

2. Adjustment of func_get_arg and func_get_args()

The two methods func_get_arg() and func_get_args() return the current value of the parameter, not the value when passed in. The current value may be modified

function foo($x) 
{
    $x++;
    var_dump(func_get_arg(0));
}
foo(1);
The above code will print 2 instead of 1. If you want to print the original value, just adjust the order of calls.

3. The modified value is also displayed when printing exception traceback information.

function foo($x) 
{
    $x = 42;
    throw new Exception;
}
foo("string");

PHP7的运行结果:Stack trace:
#0 file.php(4): foo(42)
#1 {main}

PHP5的运行结果:Stack trace:
#0 file.php(4): foo('string')
#1 {main}
This adjustment will not affect the behavior of the code, but you need to pay attention to this change when debugging.

Other functions related to parameters are subject to the same adjustment, such as debug_backtrace().

Hot AI Tools
Undress AI Tool
Undress AI Tool

Undress images for free

AI Clothes Remover
AI Clothes Remover

Online AI tool for removing clothes from photos.

Undresser.AI Undress
Undresser.AI Undress

AI-powered app for creating realistic nude photos

ArtGPT
ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT
Stock Market GPT

AI powered investment research for smarter decisions

Popular tool
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)