473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PHP4 Object handling vs PHP5

Help me here. I've become a bitconfused about how PHP4 deals with
objects after reading this description of PHP5:

"PHP's handling of objects has been completely rewritten, allowing for
better performance and more features. In previous versions of PHP,
objects were handled like primitive types (for instance integers and
strings). The drawback of this method was that semantically the whole
object was copied when a variable was assigned, or pass as a parameter
to a method. In the new approach, objects are referenced by handle,
and not by value (one can think of a handle as an object's
identifier)."

I have always assumed that PHP4 uses a copy-on-write approach, so that
when you pass an object to a function by value, PHP doesn't actually
create a new copy of that object.
Jul 17 '05 #1
2 3251
With total disregard for any kind of safety measures
ch***********@hotmail.com (Chung Leong) leapt forth and uttered:
I have always assumed that PHP4 uses a copy-on-write approach,
so that when you pass an object to a function by value, PHP
doesn't actually create a new copy of that object.


In PHP4 all variables are passed by value unless you explicitly tell
it to pass by reference. So unless you use the & when passing an
object to a function/method PHP4 will create a copy.

--
There is no signature.....
Jul 17 '05 #2
Phil Roberts <ph*****@HOLYflatnetSHIT.net> wrote in message news:<Xn*************************@206.127.4.22>...
With total disregard for any kind of safety measures
ch***********@hotmail.com (Chung Leong) leapt forth and uttered:
I have always assumed that PHP4 uses a copy-on-write approach,
so that when you pass an object to a function by value, PHP
doesn't actually create a new copy of that object.


In PHP4 all variables are passed by value unless you explicitly tell
it to pass by reference. So unless you use the & when passing an
object to a function/method PHP4 will create a copy.


The question is, does it create a physical copy (using up extra
memory) or a virtual copy (a physical copy happens only if one of the
copies is modified)?
Jul 17 '05 #3

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

Similar topics

5
by: Tim Tyler | last post by:
I'm sure this is a FAQ - but I could not find a coherent statement of the answer: Some of my clients want PHP4. Other ones want PHP5. Can I run both PHP4 and PHP5 under the same instance of...
5
by: Jan Pieter Kunst | last post by:
(apologies if this message is a duplicate -- my news server seems to have problems) Greetings, When using PHP 4, this: // ex. 1 class A { function A(&$obj) {
4
by: Kevin | last post by:
Hi all, I've got a PHP4 app that I developed which I'm trying to get to run on a PHP5 server. Everything works great, except for one thing. There's a particular routine that creates an...
5
by: sinister | last post by:
I'm starting a database/web interface project, using Linux and postgresql. I've programmed in PHP4 in the past, and for this new project am unsure whether to use PHP4 or PHP5. My main concerns...
2
by: Stefan Huber | last post by:
Hi I've got a really strange problem, and can't find out why it's not working as intended. in order to use php4 and 5 together on a webserver and the requirement for running as different...
7
by: Mathieu Maes | last post by:
Hi there I'm quite experienced in programming in PHP4, but I would like to make a step to PHP5. I created following class which works perfectly in PHP4 : Class Nessi { // ident part
35
by: Steve JORDI | last post by:
Hi, I'm trying to implement a singleton in PHP4 but it doesn't seem to work. The object is recreated each time I call it. The goal of the class is to keep a variable up to date. It's used to...
8
by: FFMG | last post by:
Hi, I am slowly moving my code to php5. But I would like to make it backward compatible in case something bad happens, (and to make sure I understand what the changes are). The way the...
14
by: Jeff | last post by:
I'm working on a server that is running PHP4. I'd like to upgrade this so I can use the PHP5 code I have already. What kind, if any, problems will I have with the existing PHP code base? I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.