PHP Libxml Functions – دوال Libxml في PHP
=======================
تُستخدم [شركة برمجة مصرية] دوال Libxml في PHP للتحكم في كيفية تحليل XML باستخدام مكتبة libxml.
libxml_clear_errors()
———————–
تحذف جميع الأخطاء المخزنة داخليًا.
<?php
libxml_use_internal_errors(true);
simplexml_load_string("<note></note><extra>");
libxml_clear_errors();
?>
libxml_disable_entity_loader()
——————————- [شركة برمجة مصرية]
تعطيل تحميل الكيانات الخارجية (مفيد للحماية).
<?php
libxml_disable_entity_loader(true);
?>
libxml_get_errors()
——————–
ترجع جميع الأخطاء ككائنات.
<?php
libxml_use_internal_errors(true);
simplexml_load_string("<note><to></note>");
$errors = libxml_get_errors();
print_r($errors);
?>
libxml_get_last_error()
————————-
ترجع آخر خطأ.
<?php
libxml_use_internal_errors(true);
simplexml_load_string("<note><to></note>");
$error = libxml_get_last_error();
echo $error->message;
?>
libxml_set_external_entity_loader()
————————————-
تُحدد لود مخصص للكيانات الخارجية.
<?php
function myEntityLoader($public, $system, $context) {
return fopen('safe.xml', 'r');
}
libxml_set_external_entity_loader('myEntityLoader');
?>
libxml_use_internal_errors()
——————————
تحدد ما إذا كان سيتم استخدام إدارة الأخطاء داخليًا.
<?php
libxml_use_internal_errors(true);
$xml = simplexml_load_string("<note></note><");
if ($xml === false) {
echo "حدث خطأ";
}
?>
