parse_str(parse_url($url, PHP_URL_QUERY), $query);
echo implode('', array_values($query));https://ideone.com/aSKxnV
substr($test, -1);
$dom = new \DOMDocument;
$dom->loadXML( $html );
$output = $dom->saveHTML((new \DOMXPath($dom))->query('/')->item(0));https://3v4l.org/2D0kK
echo $var используйте echo $var ?? ''