how to get entity reference field value on drupal 8?

by wuchuan   Last Updated December 19, 2017 08:07 AM

I tried to get the value of entity reference field by below code :

$nid = \Drupal::routeMatch()->getRawParameter('node');

$node = Node::load($nid);

$machine = $node->get('machine ')->value;

but it's empty . how can I get the correct value?

Tags : fields entities

Related Questions

How to properly delete fields, programmatically?

Updated March 20, 2017 13:07 PM