Issues (146)

examples/at_a_glance.php (2 issues)

1
<?php
2
require '../src/qp.php';
3
$xml =<<<EOF
4
<?xml version="1.0"?>
5
<table>
6
  <tr id="row1">
7
    <td>one</td><td>two</td><td>three</td>
8
  </tr>
9
  <tr id="row2">
10
    <td>four</td><td>five</td><td>six</td>
11
  </tr>
12
  </table>
13
EOF;
14
15
print "\nExample 1: \n";
16
// Get all of the <td> elements in the document and add the
17
// attribute `foo='bar'`:
18
qp($xml, 'td')->attr('foo', 'bar')->writeXML();
19
20
print "\nExample 2: \n";
21
22
// Or print the contents of the third TD in the second row:
23
print qp($xml, '#row2>td:nth(3)')->text();
0 ignored issues
show
Are you sure qp($xml, '#row2>td:nth(3)')->text() of type QueryPath\DOMQuery|string can be used in print()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

23
print /** @scrutinizer ignore-type */ qp($xml, '#row2>td:nth(3)')->text();
Loading history...
24
25
print "\nExample 3: \n";
26
// Or append another row to the XML and then write the 
27
// result to standard output:
28
qp($xml, 'tr:last')->after('<tr><td/><td/><td/></tr>')->writeXML();
29
30
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
31