reference/tokenizer/examples.xml
23fef04c872071ca5665fd75e8f4270ca960fb78
...
...
@@ -4,7 +4,7 @@
4
4
<appendix xml:id="tokenizer.examples">
5
5
&reftitle.examples;
6
6
<para>
7
-
Here is a simple example PHP scripts using the tokenizer that
7
+
Here is a simple example PHP script using the tokenizer that
8
8
will read in a PHP file, strip all comments from the source
9
9
and print the pure code only.
10
10
</para>
...
...
@@ -13,20 +13,6 @@
13
13
<programlisting role="php">
14
14
<![CDATA[
15
15
<?php
16
-
/*
17
-
* T_ML_COMMENT does not exist in PHP 5.
18
-
* The following three lines define it in order to
19
-
* preserve backwards compatibility.
20
-
*
21
-
* The next two lines define the PHP 5 only T_DOC_COMMENT,
22
-
* which we will mask as T_ML_COMMENT for PHP 4.
23
-
*/
24
-
if (!defined('T_ML_COMMENT')) {
25
-
define('T_ML_COMMENT', T_COMMENT);
26
-
} else {
27
-
define('T_DOC_COMMENT', T_ML_COMMENT);
28
-
}
29
-

30
16
$source = file_get_contents('example.php');
31
17
$tokens = token_get_all($source);
32
18

...
...
@@ -40,8 +26,7 @@ foreach ($tokens as $token) {
40
26

41
27
switch ($id) {
42
28
case T_COMMENT:
43
-
case T_ML_COMMENT: // we've defined this
44
-
case T_DOC_COMMENT: // and this
29
+
case T_DOC_COMMENT:
45
30
// no action on comments
46
31
break;
47
32

48
33