Convert URL object to string
There’s a method in the moodle_url class in lib/weblib.php called __toString() which will convert a Moodle URL object back to a string if you just need the URL string itself.
$PAGE->url->__toString()
There’s a method in the moodle_url class in lib/weblib.php called __toString() which will convert a Moodle URL object back to a string if you just need the URL string itself.
$PAGE->url->__toString()