input

construct new object

construct new object

construct new object

output
object(Node)[3]
  public 'str' => string 'third' (length=5)
  public 'ref' => 
    object(Node)[2]
      public 'str' => string 'second' (length=6)
      public 'ref' => 
        object(Node)[1]
          public 'str' => string 'first' (length=5)
          public 'ref' => null
third
destruct of -> third
second
destruct of -> second
first
destruct of -> first

class Node
{
    var $str;
    var $ref;
    function __construct() { echo '<br/>construct new object<br/>'; }
    function __destruct() { echo '<br/>destruct of -> '.$this -> str.'<br/>'; }
}

echo '<br/>input<br/>';

//
$first = new Node;
$first -> str = 'first';

//
$second = new Node;
$second -> str = 'second';
$second -> ref = $first;
$first = $second;
unset( $second ); //

//
$second = new Node;
$second -> str = 'third';
$second -> ref = $first;
$first = $second;
unset( $second ); //

echo '<br/>output<br/>';

var_dump( $first );

//
echo $first -> str;

$first = $first -> ref;

//
echo $first -> str;

$first = $first -> ref;

//
echo $first -> str;

$first = $first -> ref;

// Notice: Trying to get property of non-object
// echo $first -> str;
// $first = $first -> ref;

//for ( ; $first -> ref ; $first = $first -> ref )

// $first -> ref = NULL;

// var_dump( $first );

------------------------

input

construct new object

construct new object

construct new object

output
object(Node)[3]
  public 'str' => string 'third' (length=5)
  public 'ref' => 
    object(Node)[2]
      public 'str' => string 'second' (length=6)
      public 'ref' => 
        object(Node)[1]
          public 'str' => string 'first' (length=5)
          public 'ref' => null
thirdsecondfirst
destruct of -> third

destruct of -> second

destruct of -> first



 class Node
{
    var $str;
    var $ref;
    function __construct() { echo '<br/>construct new object<br/>'; }
    function __destruct() { echo '<br/>destruct of -> '.$this -> str.'<br/>'; }
}

echo '<br/>input<br/>';

//
$first = new Node;
$first -> str = 'first';

//
$second = new Node;
$second -> str = 'second';
$second -> ref = $first;
$first = $second;
// unset( $second ); //

//
$second = new Node;
$second -> str = 'third';
$second -> ref = $first;
$first = $second;
// unset( $second ); //

echo '<br/>output<br/>';

var_dump( $first );

//
echo $first -> str;

$first = $first -> ref;

//
echo $first -> str;

$first = $first -> ref;

//
echo $first -> str;

$first = $first -> ref;

// Notice: Trying to get property of non-object
// echo $first -> str;
// $first = $first -> ref;

//for ( ; $first -> ref ; $first = $first -> ref )

// $first -> ref = NULL;

// var_dump( $first );

-------------

// Реализация обновления поля hr_id
    $('#fio').change( function() {
        $('#hr_id').val('');
    });

-------

example on Java