# searchpro/1.9.4/simplehtmldom/example/example_callback.php

BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS &amp; JavaScript, version 1.9.4. 28 lines.

- Page: https://pluginprobe.com/plugins/searchpro/1.9.4/code/simplehtmldom/example/example_callback.php
- Raw: https://pluginprobe.com/plugins/searchpro/1.9.4/raw/simplehtmldom/example/example_callback.php
- Modified: 2024-08-20T18:00:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/searchpro/1.9.4/code/simplehtmldom/example/example_callback.php#L10-L20`.

```php
<?php
include_once('../simple_html_dom.php');


// 1. Write a function with parameter "$element"
function my_callback($element) {
    if ($element->tag=='input')
        $element->outertext = 'input';

    if ($element->tag=='img')
        $element->outertext = 'img';

    if ($element->tag=='a')
        $element->outertext = 'a';
}


// 2. create HTML Dom
$html = file_get_html('http://www.google.com/');


// 3. Register the callback function with it's function name
$html->set_callback('my_callback');


// 4. Callback function will be invoked while dumping
echo $html;
?>
```
