Home Backend Development PHP Tutorial 将要喷php5的Call-time pass-by-reference has been removed

将要喷php5的Call-time pass-by-reference has been removed

Jun 13, 2016 pm 01:17 PM
amp get php reference

就要喷php5的Call-time pass-by-reference has been removed

Call-time pass-by-reference has been removed

情况大家网上自己搜,简单点说就是移除了在调用函数时写foo(&$var)


这样做真的合理吗

首先,我当初对这种调用方式并不是很熟,我原以为像C#的ref一样,定义的有&那调用时也要有,配对出现,很合理。

但看现在的说明,看来php原来是很自由的:调用时有&,那就是传参,定义时有&也是传参,二者有其一即可。

现在的情况是取消了调用时写&的方式,只能在定义时用。

但这样忽略了另一种使用上的问题

function foo(& $var) {
   //other code
}

像这样的定义,调用时写foo(&$var)这样我就明确知道,这个参数可能被改掉,而不用去实际的函数定义里查看它会不会被改,这是一个明确的预期。

虽然语言上支持定义时写&调用时不写,但项目管理上如果规定这样写,可以减少很多不必要的BUG,比如调用别人的函数时莫名其妙的值就被改了,会产生一些不能预知的问题。

现在统一在调用时不写了,我们将难以预期函数的行为,设计PHP语法的人脑子进水了吗?


还有php升级版本时老是不能兼容原版本――改配置,取消配置,取消函数,等等。搞出巨量问题,.net是这样的吗,完全没有一个良好的设计,让开发人员完全无所适从。


随便说一句

取消了$HTTP_GET_VARS之类的定义,可以用这样一句简单的统一实现,以免修改太多代码

$HTTP_GET_VARS = $_GET;

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Working with Database CakePHP Working with Database Sep 10, 2024 pm 05:25 PM

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles