Il sab, 2003-02-22 alle 14:57, michel 'ziobudda' morelli ha scritto:
> Hi, I have this code:
Hi again.
In my script I have noticed that if I write:
protected $protetta = "Io sono protetta";
the function
function ex2()
{
echo "sono in ex2()<br>\n";
echo "\$Protetta: ".$this->protetta."<br>\n";
$this->exe2();
}
works (it writes $Protetta: Io sono protetta), but if I write
var $protetta = "Io sono protetta";
the same function write only $Prottetta:
I think that If I do not declare $protetta like "protected" it is
pubblic so it is usable from "extend classess" and other script. Why not
?
Here the new script:
<?php
error_reporting(E_ALL);
class esempio {
var $pubblica;
private $privata = "Io sono privata";
//var $protetta = "Io sono protetta";
protected $protetta = "Io sono protetta";
function esempio()
{
echo "sono in esempio::esempio()<br>\n";
}
function __construct()
{
echo "nel costruttore di A<br>\n";
}
function exe2()
{
echo "sono in exe2()<br>\n";
echo "\$Prottetta: ".$this->protetta."<br>\n";
}
function __destruct()
{
echo "<br>io sono il distruttore di esempio";
}
}
class exe extends esempio {
function __construct()
{
echo "sono in exe::__construct()<br>\n";
}
function exe()
{
echo "sono in exe::exe()<br>\n";
}
function ex2()
{
echo "sono in ex2()<br>\n";
echo "\$Protetta: ".$this->protetta."<br>\n";
$this->exe2();
}
function __destruct()
{
echo "<br>io sono il distruttore";
}
}
$n = new exe;
$n->ex2();
?>
--
michel 'ziobudda' morelli <[EMAIL PROTECTED]>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php