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

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 how to delete plugins in openinviter
2 aababu 233 Wed Sep 01, 2010 7:27 am
aartylamba View latest post
No new posts ERROR IN PAYPAL PRO
0 tapati 20 Tue Aug 31, 2010 12:35 pm
tapati View latest post
No new posts file_exists always return false
0 orenk 114 Mon Aug 16, 2010 9:49 pm
orenk View latest post
No new posts problem with include fuction
0 bluearrow 117 Mon Aug 16, 2010 1:02 pm
bluearrow View latest post
No new posts Javascript not working in smarty .tpl files
1 samir 107 Mon Aug 16, 2010 5:42 am
venkatadapa View latest post
No new posts Add slashes automatically to all post params
0 samir 111 Mon Aug 16, 2010 5:18 am
samir View latest post
No new posts SMTP server settings when send mails through phpmailer class
0 venkatadapa 96 Mon Aug 16, 2010 4:49 am
venkatadapa View latest post
No new posts Parse the xml string content and display in browser using JS
0 venkatadapa 114 Mon Aug 09, 2010 1:22 pm
venkatadapa View latest post
No new posts Parse the xml file content and display in browser using JS
0 venkatadapa 119 Mon Aug 09, 2010 1:18 pm
venkatadapa View latest post
No new posts hipay
1 hassene003 142 Mon Aug 09, 2010 12:35 pm
aababu 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