Clone behaviour - cannot set attribute value for clone?
Posted
by Dave Jarvis
on Stack Overflow
See other posts from Stack Overflow
or by Dave Jarvis
Published on 2010-04-15T07:37:03Z
Indexed on
2010/04/15
7:53 UTC
Read the original article
Hit count: 601
This code does not function as expected:
// $field contains the name of a subclass of WMSInput.
$fieldClone = clone $field;
echo $fieldClone->getInputName();
// Method on abstract WMSInput superclass.
$fieldClone->setInputName( 'name' );
echo $fieldClone->getInputName();
The WMSInput
class:
abstract class WMSInput {
private $inputName;
public function setInputName( $inputName ) {
$this->inputName = $inputName;
}
}
There are no PHP errors (error reporting is set to E_ALL).
Actual Results
email
email
Expected Results
email
name
Any ideas?
© Stack Overflow or respective owner