Jump to content

OOP Problem


Demonic

Recommended Posts

If you want to do something with variables defined in your class, you must use a $this pointer to access it within the class.

[code=php:0]
class MyClass {
  var $statement;
  function PrintToScreen(){
  echo $this->statement;
  }
  }
  $class = new MyClass;
  $class->statement = "hi";
  $class->PrintToScreen();
[/code]
Link to comment
https://forums.phpfreaks.com/topic/19546-oop-problem/#findComment-85053
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.