---
title: "PHP显示Deprecated: Assigning the return value of new by reference is deprecated in"
author: "jcyzone"
date: "2013-04-09T15:41:53Z"
tags: []
categories: ["编程语言"]
slug: "php-deprecated-assigning-the-return-value-of-new-by-reference-is-deprecated-in"
draft: false
lastmod: "2013-04-09T15:41:52Z"
id: 1810055
url: "https://jcyzone.iteye.com/blog/1810055"
---

昨晚用Spreadsheet\_Excel\_Reader导入EXCEL内容到数据库的时候，出现了以下提示：

> Deprecated: Assigning the return value of new by reference is deprecated in

定位到出错的那一行：

```
$this->_ole =& new OLERead();
```

我本地环境用的是PHP/5.3.3。

解决办法：php5.3开始后，废除了php中的”=&”符号，所以要想复制，直接用=引用即可。详细如下：

> 1、PHP5对象复制是采用引用的方式；  
> 2、如果不采用引用方式，则需要在复制对象时加关键字 clone;  
> 3、如果在复制的过程中，同时要变更某些属性，则增加函数\_clone();