473,513 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ERROR: signing the return value of new by reference

I have the following PHP code. I am using PHP 5.1.6.

$req =& new HTTP_Request($this->accessUrl);

I am getting the following errors:
Strict Standards: Assigning the return value of new by reference is
deprecated in c:\mysite\lib\simpleTest.php on line 80

Can anyone tell why is this? Does it mean assigning the return value
of new by reference is not supported in PHP 5.1.6?

Dec 19 '06 #1
5 2003
On 19 Dec 2006 14:27:26 -0800, "johnny" <ra*******@gmail.comwrote:
>I have the following PHP code. I am using PHP 5.1.6.

$req =& new HTTP_Request($this->accessUrl);

I am getting the following errors:
Strict Standards: Assigning the return value of new by reference is
deprecated in c:\mysite\lib\simpleTest.php on line 80

Can anyone tell why is this? Does it mean assigning the return value
of new by reference is not supported in PHP 5.1.6?
Objects are always passed by reference in PHP 5 hence the warning of
deprecation of the effective double-reference.

Obviously if you have to support PHP 4 then you must keep the & - in which
case you need to disable E_STRICT from error_reporting.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Dec 19 '06 #2

Andy Hassall schrieb:
On 19 Dec 2006 14:27:26 -0800, "johnny" <ra*******@gmail.comwrote:
I have the following PHP code. I am using PHP 5.1.6.

$req =& new HTTP_Request($this->accessUrl);

I am getting the following errors:
Strict Standards: Assigning the return value of new by reference is
deprecated in c:\mysite\lib\simpleTest.php on line 80

Objects are always passed by reference in PHP 5 hence the warning of
deprecation of the effective double-reference.

Obviously if you have to support PHP 4 then you must keep the & - in which
case you need to disable E_STRICT from error_reporting.
Just for the sake of clearness: Any assignment of an object to a
variable creates a copy of the object? A shallow object, I suppose?

Dec 20 '06 #3
Why would you want to do that...
I mean assigning reference to a newly created
object just doesn't make sense...
$req = new HTTP_Request($this->accessUri);
will just do.

IMHO

johnny wrote:
I have the following PHP code. I am using PHP 5.1.6.

$req =& new HTTP_Request($this->accessUrl);

I am getting the following errors:
Strict Standards: Assigning the return value of new by reference is
deprecated in c:\mysite\lib\simpleTest.php on line 80

Can anyone tell why is this? Does it mean assigning the return value
of new by reference is not supported in PHP 5.1.6?
Dec 20 '06 #4
On 19 Dec 2006 17:42:29 -0800, "seaside" <se********@mac.comwrote:
>Andy Hassall schrieb:
>On 19 Dec 2006 14:27:26 -0800, "johnny" <ra*******@gmail.comwrote:
>I have the following PHP code. I am using PHP 5.1.6.

$req =& new HTTP_Request($this->accessUrl);

I am getting the following errors:
Strict Standards: Assigning the return value of new by reference is
deprecated in c:\mysite\lib\simpleTest.php on line 80

Objects are always passed by reference in PHP 5 hence the warning of
deprecation of the effective double-reference.

Obviously if you have to support PHP 4 then you must keep the & - in which
case you need to disable E_STRICT from error_reporting.

Just for the sake of clearness: Any assignment of an object to a
variable creates a copy of the object? A shallow object, I suppose?
Assignment with "=" instead of "=&" on PHP4 creates a shallow copy of the
object.

Assignment with "=" on PHP5 does not create a copy; you use the clone keyword
for that, which by default makes a shallow copy, but you can override the
__clone() method in the object to do any deep copying or other operations if
required.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Dec 20 '06 #5
..oO(Hendri Kurniawan)
>Why would you want to do that...
I mean assigning reference to a newly created
object just doesn't make sense...
In PHP 4 it did.
>$req = new HTTP_Request($this->accessUri);
will just do.
This code executed in PHP 4 would have created _two_ objects: the one
created by "new" and a copy of it assigned to $req.

Micha
Dec 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2123
by: xuatla | last post by:
Hi, I encountered the following compile error of c++ and hope to get your help. test2.cpp: In member function `CTest CTest::operator+=(CTest&)': test2.cpp:79: error: no match for 'operator='...
12
4103
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
0
7778
by: Scott Chang | last post by:
Hi all, I have Microsoft Visual C++ .NET (2002) program that is installed on my Windows XP Professional Operating System PC. I started my project (named HelloMCPP)in the Managed C++ Application...
2
1622
by: Richard B | last post by:
I added a .NET dll as a reference to my new .NET dll. When I went to build, I received error "Unable to emit assembly: Referenced assembly 'CrystalReport' does not have a strong name". ...
0
489
by: Alun Jones | last post by:
I'm getting the above error in a dialog box from Visual Studio 2005 when trying to sign an assembly using a PFX file, and would like to know how to resolve the problem. Background: The PFX...
2
2318
by: arun1985 | last post by:
In the project i am using i am having the following code and when i upload it to the server.Its givig me the following error in the global.cs file. Server Error in '/' Application. ...
6
5644
by: raylopez99 | last post by:
Anybody use Strong Name Signing? I think this is used by default for Resource files, which is one reason perhaps I can't get my resource files to work (somehow the public key is messed up, perhaps...
1
5209
by: Bhrionn | last post by:
Hello World, I am working on implementing a build for my companies application. The scenario implemeted is producing the error: ‘Class does not support automation or does not support expected...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7523
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.