Jump to content

PHP Syntax problem "->"


lucerias

Recommended Posts

It's used to access an object's methods and properties (aka functions and variables).  An object is created when you instantiate a variable with a class.  For example:

[code]
class myClass{
  var name;
  var phone;
  function showPhone()
    //"this" is a special variable which allows methods (functions) in this class to access variables that are part of this object.
    echo $this->phone;
  }
}
$test as new myClass;
$test->name = "Don";
$test->phone = "215-333-9999";
$test->showPhone();  //        <--this will echo to the browser "215-333-9999"
[/code]
Link to comment
https://forums.phpfreaks.com/topic/26783-php-syntax-problem/#findComment-122491
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.