<?php
class MinhaClasse
{
function __construct() {
$this->arr['ano'] = date('s'); // Pus "segundos" pra demonstrar. }
public function getAno()
{
return $this->arr['ano'];
}
}
$objeto1 = new MinhaClasse();
echo $objeto1 ->getAno()."\n";
sleep( 2 ); // Atraso para mostrar o efeito colateral
$objeto2 = new MinhaClasse();
echo $objeto2 ->getAno()."\n";
PD9waHAKICAgICAgICAKICAgIGNsYXNzIE1pbmhhQ2xhc3NlCiAgICB7ICAgCiAgICAgICAgcHVibGljICRhcnIgPSBhcnJheSgpOwoKICAgICAgICBmdW5jdGlvbiBfX2NvbnN0cnVjdCgpIHsKICAgICAgICAgICAgJHRoaXMtPmFyclsnYW5vJ10gPSBkYXRlKCdzJyk7IC8vIFB1cyAic2VndW5kb3MiIHByYSBkZW1vbnN0cmFyLgogICAgICAgIH0KCiAgICAgICAgcHVibGljIGZ1bmN0aW9uIGdldEFubygpCiAgICAgICAgeyAgICAgICAgICAgICAgCiAgICAgICAgICAgIHJldHVybiAkdGhpcy0+YXJyWydhbm8nXTsKICAgICAgICB9CiAgICB9CiAgICAKICAgICRvYmpldG8xID0gbmV3IE1pbmhhQ2xhc3NlKCk7CiAgICBlY2hvICRvYmpldG8xIC0+Z2V0QW5vKCkuIlxuIjsKICAgIAogICAgc2xlZXAoIDIgKTsgLy8gQXRyYXNvIHBhcmEgbW9zdHJhciBvIGVmZWl0byBjb2xhdGVyYWwKICAgIAogICAgJG9iamV0bzIgPSBuZXcgTWluaGFDbGFzc2UoKTsKICAgIGVjaG8gJG9iamV0bzIgLT5nZXRBbm8oKS4iXG4iOw==