Example 1 — Turn Internal Errors On
Enable internal errors and see how the return value reports the previous setting.
<?php
$previous = libxml_use_internal_errors(true);
echo "Previous: ", var_export($previous, true), PHP_EOL;
$current = libxml_use_internal_errors();
echo "Now: ", var_export($current, true), PHP_EOL; How It Works
- By default libxml prints warnings, so the previous setting is false.
- Calling libxml_use_internal_errors(true) switches on error collection.
- Calling it again with no argument leaves the setting unchanged.
- That second call returns true, the current state.

