Using -> operator for declarations?
| From: | Marco Skulschus | Date: | Fri, 02 Jan 2004 13:50:17 +0000 |
| Subject: | Using -> operator for declarations? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-173631@lists.php.net to get a copy of this message | ||
Maybe, it was "correct" even in the past, but I am astonished that the
following special "variable declaration" works. Although there is not var
$MissingText in the class, one can fill it with data and pass it to the
object.
<?php
class Output {
var $Text;
function PrintOutput($Text){
echo $Text;
}
}
$Message = new Output();
// first attempt
$Message -> Text = "Hello World";
$Message -> PrintOutput($Message -> Text);
// second attempt
$Message -> MissingText = "Hello Moon";
$Message -> PrintOutput($Message -> MissingText);
?>
Maybe you can correct me.
Marco