| 1 |
Provides the ability to see debug messages for deprecated functions, malformed documents and parsing issues. Debug messages can be sent to a custom message handler or written to error_log (default). |
| 2 |
|
| 3 |
## Example |
| 4 |
|
| 5 |
```php |
| 6 |
<?php |
| 7 |
include_once 'HtmlDocument.php'; |
| 8 |
include_once 'Debug.php'; |
| 9 |
use simplehtmldom\HtmlDocument; |
| 10 |
use simplehtmldom\Debug; |
| 11 |
|
| 12 |
Debug::enable(); |
| 13 |
|
| 14 |
$dom = new HtmlDocument(); |
| 15 |
$dom->load('<html></html>'); |
| 16 |
$dom->root->children(); // This causes a deprecation warning |
| 17 |
|
| 18 |
Debug::disable(); |
| 19 |
``` |
| 20 |
|
| 21 |
**Output** |
| 22 |
|
| 23 |
``` |
| 24 |
[DEBUG] [/var/www/html/simplehtmldom/Debug.php:30] [/var/www/html/simplehtmldom/test.php:7] "Debug mode has been enabled" |
| 25 |
[DEBUG] [/var/www/html/simplehtmldom/HtmlNode.php:83] [/var/www/html/simplehtmldom/test.php:11] "simplehtmldom\HtmlNode->children() has been deprecated and will be removed in the next major version of simplehtmldom. Use simplehtmldom\HtmlNode->childNodes() instead." |
| 26 |
[DEBUG] [/var/www/html/simplehtmldom/Debug.php:38] [/var/www/html/simplehtmldom/test.php:13] "Debug mode has been disabled" |
| 27 |
``` |