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