" in Drupal? I run this -> in Drupal and cannot find any documents on it. I use it like this print $node->content['field_pr_lin...">

What is this: "->" in Drupal?

I run this -> in Drupal and cannot find any documents on it.

I use it like this print $node->content['field_pr_link'];

Is this a Drupal or PHP thing?

+4
source share
3 answers

This is PHP. You use it to access the content field of the node object.

See http://php.net/manual/en/language.oop5.php

+10
source

This is a PHP Operator object. This is very poorly documented in the PHP manual. It allows you to refer to variables, constants, and methods of an object.

 $a = $ObjectInstance->var; # get variable or constant $ObjectInstance->var2 = "string"; # set variable $ObjectInstance->method(); # invoke a method. 
+1
source

This is an operator used in the scope of an object to access its variables and methods.

Imagine you have the following class:

 class Object { protected $variable; public function setVariable($variable) { $this->variable = $variable; } public function getVariable() { return $this->variable; } } 

You can see that I am accessing variables within this class ( $this ) using the -> operator. When I instantiate, I access public methods / variables from the same scope using the same statement:

 $object = new Object(); $object->setVariable('Hello world'); echo $object->getVariable(); // 'Hello world' 

In your case, $node represents an object and content is a public variable inside that object.

+1
source

All Articles