Convert $page field value to int

That’s a limitation of PHP. Objects can only be automatically converted to strings (using the __toString() method), not to other data types.

You can use the following though (a string can easily be converted to an int):

echo (int)(string)$page->my_field();

But yes, using ->value() is easier to understand and the way to go.

1 Like