I can echo the object out, but I cannot use it any comparison inside the Loop.
But, bizarrely, even if I perform the conversion outside of the Loop — which works — the moment I use the new string variable — no matter what its name is — back inside the Loop, I get the same error.
This is utterly baffling. I’ve never see anything like this. It’s like it knows what I’m trying to do and it won’t let me!
Create a new class and define the magic __toString method of that class. This function is invoked any time the object is asked for a string representation of itself. Since it’s a function you’ll have full control of what gets output by the class. Further, since you’ve defined the behavior of the object when converted to a string the error will not be raised.
Well that’s what I’ve been looking at, but I can’t see why I’ve got to create a class and a method just so I can compare the values of two objects, both of which contain nothing more than string values.
PHP is meant to handle all of this on the fly. Since that’s failed, I’ve tried converting the object and that’s failed too.