xref: /PHP-8.1/sapi/cli/tests/017.phpt (revision 39131219)
1--TEST--
2CLI -a and libedit
3--EXTENSIONS--
4readline
5--SKIPIF--
6<?php
7include "skipif.inc";
8if (readline_info('done') !== NULL) {
9    die ("skip need readline support using libedit");
10}
11if(substr(PHP_OS, 0, 3) == 'WIN' ) {
12    die('skip not for Windows');
13}
14?>
15--FILE--
16<?php
17$php = getenv('TEST_PHP_EXECUTABLE');
18
19$codes = array();
20
21$codes[1] = <<<EOT
22echo 'Hello world';
23exit
24EOT;
25
26$codes[] = <<<EOT
27echo 'multine
28single
29quote';
30exit
31EOT;
32
33$codes[] = <<<EOT
34echo <<<HEREDOC
35Here
36comes
37the
38doc
39HEREDOC;
40EOT;
41
42$codes[] = <<<EOT
43if (0) {
44    echo "I'm not there";
45}
46echo "Done";
47EOT;
48
49$codes[] = <<<EOT
50function a_function_with_some_name() {
51    echo "I was called!";
52}
53a_function_w	);
54EOT;
55
56foreach ($codes as $key => $code) {
57    echo "\n--------------\nSnippet no. $key:\n--------------\n";
58    $code = escapeshellarg($code);
59    echo `echo $code | "$php" -a`, "\n";
60}
61
62echo "\nDone\n";
63?>
64--EXPECT--
65--------------
66Snippet no. 1:
67--------------
68Interactive shell
69
70Hello world
71
72
73--------------
74Snippet no. 2:
75--------------
76Interactive shell
77
78multine
79single
80quote
81
82
83--------------
84Snippet no. 3:
85--------------
86Interactive shell
87
88Here
89comes
90the
91doc
92
93
94--------------
95Snippet no. 4:
96--------------
97Interactive shell
98
99Done
100
101
102--------------
103Snippet no. 5:
104--------------
105Interactive shell
106
107
108Parse error: Unmatched ')' in php shell code on line 1
109
110
111Done
112