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: 74

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 Create view and setting the path in drupal
0 Thirupathi 3 Mon Mar 22, 2010 11:50 am
Thirupathi View latest post
No new posts Views module configuration in drupal
0 Thirupathi 2 Mon Mar 22, 2010 11:43 am
Thirupathi View latest post
No new posts Php script to post multiple selectd values
0 Thirupathi 2 Mon Mar 22, 2010 11:30 am
Thirupathi View latest post
No new posts How to set the custom front page in drupal
0 Thirupathi 5 Mon Mar 22, 2010 4:31 am
Thirupathi View latest post
No new posts How to get detailed information about server.
0 AnilKumar 9 Mon Mar 22, 2010 3:42 am
AnilKumar View latest post
No new posts Upload large file using htaccess file in php
0 AnilKumar 14 Fri Mar 19, 2010 7:06 am
AnilKumar View latest post
No new posts subtracting tha dates from present date using php
0 rajkumar 16 Fri Mar 19, 2010 4:58 am
rajkumar View latest post
No new posts How to change Admin theme in drupal
0 Thirupathi 15 Fri Mar 19, 2010 4:48 am
Thirupathi View latest post
No new posts problem with plesk
1 Sanjana 18 Fri Mar 19, 2010 4:41 am
rajkumar View latest post
No new posts Pagination in smarty using php and mysql
0 AnilKumar 18 Fri Mar 19, 2010 4:06 am
AnilKumar 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