xref: /PHP-8.3/sapi/cgi/tests/003.phpt (revision c5401854)
1--TEST--
2strip comments and whitespace with -w
3--SKIPIF--
4<?php
5
6if (substr(PHP_OS, 0, 3) == 'WIN') {
7    die ("skip not for Windows");
8}
9
10include "skipif.inc";
11?>
12--FILE--
13<?php
14
15include "include.inc";
16
17$php = get_cgi_path();
18reset_env_vars();
19
20$filename = __DIR__.'/003.test.php';
21$code ='
22<?php
23/* some test script */
24
25class test { /* {{{ */
26    public $var = "test"; //test var
27#perl style comment
28    private $pri; /* private attr */
29
30    function foo(/* void */) {
31    }
32}
33/* }}} */
34
35?>
36';
37
38file_put_contents($filename, $code);
39
40var_dump(`$php -n -w "$filename"`);
41var_dump(`$php -n -w "wrong"`);
42var_dump(`echo "<?php /* comment */ class test {\n // comment \n function foo() {} } ?>" | $php -n -w`);
43
44@unlink($filename);
45
46echo "Done\n";
47?>
48--EXPECTF--
49string(%d) "X-Powered-By: PHP/%s
50Content-type: text/html%r; charset=.*|%r
51
52
53<?php
54 class test { public $var = "test"; private $pri; function foo() { } } ?>
55"
56string(%d) "Status: 404 Not Found
57X-Powered-By: PHP/%s
58Content-type: text/html%r; charset=.*|%r
59
60No input file specified.
61"
62string(%d) "X-Powered-By: PHP/%s
63Content-type: text/html%r; charset=.*|%r
64
65<?php  class test { function foo() {} } ?>
66"
67Done
68