将要喷php5的Call-time pass-by-reference has been removed
就要喷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;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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

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

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

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

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

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

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

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