How to get the values from a formatted field in inc file I have a description field with a CK editor enabled. And when I get the data from it as node-&gt;get('fieldname')-&gt;getString() it outputs the content as below.

The contents that I have entered in the Ck editor
, basic_html

I can resolve this in the twig file by getting this as {{fieldname| raw}}. But I need to get this in a php file. How do I get the value without that , basic html part?
How do I get the value without that , basic html part?


$node-&gt;field_name-&gt;value; should do the trick.




  I can resolve this in the twig file by getting this as {{fieldname|raw}}.


Using | raw filter in twig is bad security practice, see How do I get the raw field value in a twig template? for a safe solution.