Basics of OOP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

The following bit of code doesn't output anything:

<?php
    class output {
        var $text;
        function outputText() {
            $this->text = "Hello World";
            echo $this->text;
        }
    }

    $class = new output();
    $class->outputText;
?>

As well as the following code:

<?php
    class output {
        var $text=5;
        function outputText() {
            echo $this->text;
        }
    }

    $class = new output();
    $class->outputText;
?>

Am I doing anything wrong? By the way, the preceding code is just so I
understand OOP which finally I've grasped, but am I doing anything wrong as
both codes don't output anything?

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux