Example 1 — Create a Parser Object
Create a parser and check that PHP 8 gives you an XMLParser object, not a resource.
<?php
$parser = xml_parser_create();
echo get_debug_type($parser), PHP_EOL;
var_dump($parser instanceof XMLParser);
echo is_resource($parser) ? "resource" : "object", PHP_EOL; How It Works
- xml_parser_create() builds a new parser with default options.
- get_debug_type() shows that the type is XMLParser.
- instanceof confirms the value is an object of that class.
- is_resource() is false in PHP 8, so the last line prints object.

