RE: [PHP-WIN] do classes work properly? - with exe code this time From: Eduardo Jordan G. (ejordan <email protected>)
Date: 06/27/00

Hi,

When refering a data member from inside the class use
$this->var NOT $this->$var.

Notice u need only one $

Eduardo Jordán G.
ejordan <email protected>

-----Original Message-----
From: Andrew Hurley [SMTP:ahurley <email protected>]
Sent: Tuesday, June 27, 2000 8:37 AM
To: php-windows <email protected>
Subject: [PHP-WIN] do classes work properly? - with exe code this time

Hello all.

This is my code in file "table.php"

  class Test {

    var $width;
    var $height;

    function Test () {

      $this->$width = "really longgggggg";
      $this->$height = "really highhhhhh";

    }

    function serve ()

      print "This is the width: " . $this->$width . "<br>";
      print "This is the height: " . $this->$height . "<br>";

    }

  }

Used in another php file as so:

<?php

require("table.php");
$raw = new Test;
$raw->serve();

?>

The output I get is:

  This is the width: really highhhhhh
  This is the height: really highhhhhh

This happens with other classess too.

Any ideas?

Note: could it be the use of var? In the manual there is only examples of
using var with one variable, unfortunately.

I'm used to C++ where an object declares vars and funcs.

Thanks.
Andrew.

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-windows-unsubscribe <email protected>
For additional commands, e-mail: php-windows-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>

-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-windows-unsubscribe <email protected> For additional commands, e-mail: php-windows-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>