PHP 5 >= 5.4.0, PHP 7, PHP 8
libxml_set_external_entity_loader - Changes the default external entity loader
Code Examples

libxml_set_external_entity_loader( callable|null$resolver_function ): bool

Changes the default external entity loader. This can be used to suppress the expansion of arbitrary external entities to avoid XXE attacks, even when LIBXML_NOENT has been set for the respective operation, and is usually preferable over calling libxml_disable_entity_loader.



A callable with the following signature:

resolver( string$public_id, string$system_id, array$context ): resource|string|null

The public ID.


The system ID.


An array with the four elements "directory", "intSubName", "extSubURI" and "extSubSystem".

This callable should return a resource, a string from which a resource can be opened. If null is returned, the entity reference resolution will fail.

Return Values

Returns true on success or false on failure.

Related Functions

Example of libxml_set_external_entity_loader

Show all examples for libxml_set_external_entity_loader

PHP Version:

Function libxml_set_external_entity_loader:

libxml Functions

Most used PHP functions