Senior & Expert PHP Developers Discussion Forum by Nyros Technologies

HIRE PHP Expert Developers Programmers Coders From India
PHP .Net Ruby on Rails Developers Community, Nyros Technologies, Kakinada
 
Log in  or IF not a member please REGISTER
Username:
Password:   


Keyword
Log in | Profile 

Need to develop cloning concept in php5

 
Post new topic   Reply to topic    Senior & Expert PHP Developers Discussion Forum by Nyros Technologies Index -> Advanced Programming
View previous topic :: View next topic  
Author Message
Thirupathi



Joined: 01 Dec 2009
Posts: 70

PostPosted: Sat Feb 06, 2010 6:51 am    Post subject: Need to develop cloning concept in php5 Reply with quote

Hi friends,I have posted topic regarding how the cloning concept was developed in php5.What is the need of clone object.

This simple example will give you aware of cloning concept.

<?php
class Person {
var $name;
function getName() {
return $this->name;
}
function setName($name) {
$this->name = $name;
}
function Person($name) {
$this->setName($name);
}
}

function changeName($person, $name) {
$person->setName($name);
}

$person = new Person("Raj");
changeName($person, "Ratan");
print $person->getName();
?>
In PHP 4, this piece of code would print out "Raj". The reason is that we pass the object $person to the changeName() function by-value, and thus, $person is copied and changeName() works on a copy of $person.

In PHP 5, the infrastructure of the object model was rewritten to work with object handles. Unless you explicitly clone an object by using the clone keyword you will never create behind the scene duplicates of your objects. In PHP 5, there is neither a need to pass objects by reference nor assigning them by reference.

I think it might be help you.

Thanks and Regards,
Thirupathi.J
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Senior & Expert PHP Developers Discussion Forum by Nyros Technologies Index -> Advanced Programming
Page 1 of 1

 latest topics 
 Topics   Replies   Author   Views   Last Post 
No new posts Upload large file using htaccess file in php
0 AnilKumar 11 Fri Mar 19, 2010 7:06 am
AnilKumar View latest post
No new posts subtracting tha dates from present date using php
0 rajkumar 13 Fri Mar 19, 2010 4:58 am
rajkumar View latest post
No new posts How to change Admin theme in drupal
0 Thirupathi 12 Fri Mar 19, 2010 4:48 am
Thirupathi View latest post
No new posts problem with plesk
1 Sanjana 15 Fri Mar 19, 2010 4:41 am
rajkumar View latest post
No new posts Pagination in smarty using php and mysql
0 AnilKumar 16 Fri Mar 19, 2010 4:06 am
AnilKumar View latest post
No new posts highlet source code in php application
0 Sanjana 21 Thu Mar 18, 2010 11:04 am
Sanjana View latest post
No new posts Get the status from twitter using PHP script
1 Thirupathi 36 Tue Mar 16, 2010 4:41 am
Phani Kumar View latest post
No new posts Error: CakephpController could not be found.
0 Mike 19 Tue Mar 16, 2010 4:21 am
Mike View latest post
No new posts cake php
2 Mike 40 Mon Mar 15, 2010 11:46 am
Mike View latest post
No new posts Problem to create a folder in my server
1 samir 21 Mon Mar 15, 2010 7:32 am
rajkumar View latest post





Hire an expert PHP developer / coder / programmer or development team from India now!!

Other Forums : Ruby on Rails   ::   .Net   |   Free unlimited HTML CSS Joomla Wordpress Drupal templates download

Nyros Technologies   |   Developers Blog   |   Kakinada City Portal   |   About PHP Experts   |   More