xref: /PHP-8.4/sapi/cli/tests/014.phpt (revision f907a009)
1--TEST--
2syntax highlighting
3--SKIPIF--
4<?php include "skipif.inc"; ?>
5--FILE--
6<?php
7
8$php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
9
10$filename = __DIR__."/014.test.php";
11$code = '
12<?php
13$test = "var"; //var
14/* test class */
15class test {
16    private $var = array();
17
18    public static function foo(Test $arg) {
19        echo "hello";
20        var_dump($this);
21    }
22}
23
24$o = new test;
25?>
26';
27
28file_put_contents($filename, $code);
29
30$filename_escaped = escapeshellarg($filename);
31var_dump(`$php -n -s $filename_escaped`);
32var_dump(`$php -n -s unknown`);
33
34@unlink($filename);
35
36echo "Done\n";
37?>
38--EXPECT--
39string(1158) "<pre><code style="color: #000000">
40<span style="color: #0000BB">&lt;?php
41$test </span><span style="color: #007700">= </span><span style="color: #DD0000">"var"</span><span style="color: #007700">; </span><span style="color: #FF8000">//var
42/* test class */
43</span><span style="color: #007700">class </span><span style="color: #0000BB">test </span><span style="color: #007700">{
44    private </span><span style="color: #0000BB">$var </span><span style="color: #007700">= array();
45
46    public static function </span><span style="color: #0000BB">foo</span><span style="color: #007700">(</span><span style="color: #0000BB">Test $arg</span><span style="color: #007700">) {
47        echo </span><span style="color: #DD0000">"hello"</span><span style="color: #007700">;
48        </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">);
49    }
50}
51
52</span><span style="color: #0000BB">$o </span><span style="color: #007700">= new </span><span style="color: #0000BB">test</span><span style="color: #007700">;
53</span><span style="color: #0000BB">?&gt;
54</span></code></pre>"
55Could not open input file: unknown
56NULL
57Done
58