@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | HTML; |
16 | 16 | |
17 | 17 | $html = HtmlDomParser::str_get_html($str); |
18 | -echo $html->find('div div div', 0)->innertext . '<br>'; // result: "ok" |
|
18 | +echo $html->find('div div div', 0)->innertext.'<br>'; // result: "ok" |
|
19 | 19 | |
20 | 20 | // ----------------------------------------------------------------------------- |
21 | 21 | // nested selector |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $html = HtmlDomParser::str_get_html($str); |
34 | 34 | foreach ($html->find('ul') as $ul) { |
35 | 35 | foreach ($ul->find('li') as $li) { |
36 | - echo $li->innertext . '<br>'; |
|
36 | + echo $li->innertext.'<br>'; |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | $html = HtmlDomParser::str_get_html($str); |
51 | 51 | foreach ($html->find('input[type=checkbox]') as $checkbox) { |
52 | 52 | if ($checkbox->checked) { |
53 | - echo $checkbox->name . ' is checked<br>'; |
|
53 | + echo $checkbox->name.' is checked<br>'; |
|
54 | 54 | } else { |
55 | - echo $checkbox->name . ' is not checked<br>'; |
|
55 | + echo $checkbox->name.' is not checked<br>'; |
|
56 | 56 | } |
57 | 57 | } |
@@ -9,36 +9,36 @@ |
||
9 | 9 | |
10 | 10 | // find all link |
11 | 11 | foreach ($html->find('a') as $e) { |
12 | - echo $e->href . '<br>'; |
|
12 | + echo $e->href.'<br>'; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | // find all image |
16 | 16 | foreach ($html->find('img') as $e) { |
17 | - echo $e->src . '<br>'; |
|
17 | + echo $e->src.'<br>'; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | // find all image with full tag |
21 | 21 | foreach ($html->find('img') as $e) { |
22 | - echo $e->outertext . '<br>'; |
|
22 | + echo $e->outertext.'<br>'; |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | // find all div tags with id=gbar |
26 | 26 | foreach ($html->find('div#gbar') as $e) { |
27 | - echo $e->innertext . '<br>'; |
|
27 | + echo $e->innertext.'<br>'; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | // find all span tags with class=gb1 |
31 | 31 | foreach ($html->find('span.gb1') as $e) { |
32 | - echo $e->outertext . '<br>'; |
|
32 | + echo $e->outertext.'<br>'; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // find all td tags with attribite align=center |
36 | 36 | foreach ($html->find('td[align=center]') as $e) { |
37 | - echo $e->innertext . '<br>'; |
|
37 | + echo $e->innertext.'<br>'; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // extract text from table |
41 | -echo $html->find('td[align="center"]', 1)->plaintext . '<br><hr>'; |
|
41 | +echo $html->find('td[align="center"]', 1)->plaintext.'<br><hr>'; |
|
42 | 42 | |
43 | 43 | // extract text from HTML |
44 | 44 | echo $html->plaintext; |
@@ -636,7 +636,7 @@ |
||
636 | 636 | * |
637 | 637 | * @param $name |
638 | 638 | * |
639 | - * @return mixed |
|
639 | + * @return SimpleHtmlDom |
|
640 | 640 | */ |
641 | 641 | public function removeAttribute($name) |
642 | 642 | { |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | return call_user_func_array(array($this, self::$functionAliases[$name]), $arguments); |
166 | 166 | } |
167 | 167 | |
168 | - throw new BadMethodCallException('Method does not exist: ' . $name); |
|
168 | + throw new BadMethodCallException('Method does not exist: '.$name); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | |
272 | 272 | if (!empty($linksOld[1])) { |
273 | 273 | $linksOld = $linksOld[1]; |
274 | - foreach ((array)$linksOld as $linkKey => $linkOld) { |
|
274 | + foreach ((array) $linksOld as $linkKey => $linkOld) { |
|
275 | 275 | $linksNew[$linkKey] = str_replace( |
276 | 276 | self::$domLinkReplaceHelper['orig'], |
277 | 277 | self::$domLinkReplaceHelper['tmp'], |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | $xmlHackUsed = false; |
367 | 367 | if (stripos('<?xml', $html) !== 0) { |
368 | 368 | $xmlHackUsed = true; |
369 | - $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; |
|
369 | + $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html; |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | $html = self::replaceToPreserveHtmlEntities($html); |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | public function loadHtml($html, $libXMLExtraOptions = null) |
654 | 654 | { |
655 | 655 | if (!is_string($html)) { |
656 | - throw new InvalidArgumentException(__METHOD__ . ' expects parameter 1 to be string.'); |
|
656 | + throw new InvalidArgumentException(__METHOD__.' expects parameter 1 to be string.'); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | $this->document = $this->createDOMDocument($html, $libXMLExtraOptions); |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | public function loadHtmlFile($filePath, $libXMLExtraOptions = null) |
673 | 673 | { |
674 | 674 | if (!is_string($filePath)) { |
675 | - throw new InvalidArgumentException(__METHOD__ . ' expects parameter 1 to be string.'); |
|
675 | + throw new InvalidArgumentException(__METHOD__.' expects parameter 1 to be string.'); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | if (!preg_match("/^https?:\/\//i", $filePath) && !file_exists($filePath)) { |
@@ -142,7 +142,7 @@ |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | - * @return mixed |
|
145 | + * @return string |
|
146 | 146 | */ |
147 | 147 | public function __toString() |
148 | 148 | { |