diff options
Diffstat (limited to 'inc/JSLikeHTMLElement.php')
-rw-r--r-- | inc/JSLikeHTMLElement.php | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/inc/JSLikeHTMLElement.php b/inc/JSLikeHTMLElement.php index 0557205f..dfcc1be5 100644 --- a/inc/JSLikeHTMLElement.php +++ b/inc/JSLikeHTMLElement.php | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * This class extends PHP's DOMElement to allow | 5 | * This class extends PHP's DOMElement to allow |
6 | * users to get and set the innerHTML property of | 6 | * users to get and set the innerHTML property of |
7 | * HTML elements in the same way it's done in | 7 | * HTML elements in the same way it's done in |
8 | * JavaScript. | 8 | * JavaScript. |
9 | * | 9 | * |
10 | * Example usage: | 10 | * Example usage: |
@@ -15,16 +15,16 @@ | |||
15 | * $doc->registerNodeClass('DOMElement', 'JSLikeHTMLElement'); | 15 | * $doc->registerNodeClass('DOMElement', 'JSLikeHTMLElement'); |
16 | * $doc->loadHTML('<div><p>Para 1</p><p>Para 2</p></div>'); | 16 | * $doc->loadHTML('<div><p>Para 1</p><p>Para 2</p></div>'); |
17 | * $elem = $doc->getElementsByTagName('div')->item(0); | 17 | * $elem = $doc->getElementsByTagName('div')->item(0); |
18 | * | 18 | * |
19 | * // print innerHTML | 19 | * // print innerHTML |
20 | * echo $elem->innerHTML; // prints '<p>Para 1</p><p>Para 2</p>' | 20 | * echo $elem->innerHTML; // prints '<p>Para 1</p><p>Para 2</p>' |
21 | * echo "\n\n"; | 21 | * echo "\n\n"; |
22 | * | 22 | * |
23 | * // set innerHTML | 23 | * // set innerHTML |
24 | * $elem->innerHTML = '<a href="http://fivefilters.org">FiveFilters.org</a>'; | 24 | * $elem->innerHTML = '<a href="http://fivefilters.org">FiveFilters.org</a>'; |
25 | * echo $elem->innerHTML; // prints '<a href="http://fivefilters.org">FiveFilters.org</a>' | 25 | * echo $elem->innerHTML; // prints '<a href="http://fivefilters.org">FiveFilters.org</a>' |
26 | * echo "\n\n"; | 26 | * echo "\n\n"; |
27 | * | 27 | * |
28 | * // print document (with our changes) | 28 | * // print document (with our changes) |
29 | * echo $doc->saveXML(); | 29 | * echo $doc->saveXML(); |
30 | * @endcode | 30 | * @endcode |
@@ -59,7 +59,7 @@ class JSLikeHTMLElement extends DOMElement | |||
59 | $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); | 59 | $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); |
60 | // Using <htmlfragment> will generate a warning, but so will bad HTML | 60 | // Using <htmlfragment> will generate a warning, but so will bad HTML |
61 | // (and by this point, bad HTML is what we've got). | 61 | // (and by this point, bad HTML is what we've got). |
62 | // We use it (and suppress the warning) because an HTML fragment will | 62 | // We use it (and suppress the warning) because an HTML fragment will |
63 | // be wrapped around <html><body> tags which we don't really want to keep. | 63 | // be wrapped around <html><body> tags which we don't really want to keep. |
64 | // Note: despite the warning, if loadHTML succeeds it will return true. | 64 | // Note: despite the warning, if loadHTML succeeds it will return true. |
65 | $result = @$f->loadHTML('<htmlfragment>'.$value.'</htmlfragment>'); | 65 | $result = @$f->loadHTML('<htmlfragment>'.$value.'</htmlfragment>'); |
@@ -86,7 +86,7 @@ class JSLikeHTMLElement extends DOMElement | |||
86 | * @code | 86 | * @code |
87 | * $string = $div->innerHTML; | 87 | * $string = $div->innerHTML; |
88 | * @endcode | 88 | * @endcode |
89 | */ | 89 | */ |
90 | public function __get($name) | 90 | public function __get($name) |
91 | { | 91 | { |
92 | if ($name == 'innerHTML') { | 92 | if ($name == 'innerHTML') { |
@@ -106,5 +106,4 @@ class JSLikeHTMLElement extends DOMElement | |||
106 | { | 106 | { |
107 | return '['.$this->tagName.']'; | 107 | return '['.$this->tagName.']'; |
108 | } | 108 | } |
109 | } | 109 | } \ No newline at end of file |
110 | ?> \ No newline at end of file | ||