summaryrefslogtreecommitdiff
path: root/sapi/cli/tests/016.phpt
blob: bbba579ec2b247027ce4d3ed3d821998a63c3c41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
--TEST--
CLI -a and readline
--SKIPIF--
<?php
include "skipif.inc";
if (!extension_loaded('readline') || readline_info('done') === NULL) {
	die ("skip need readline support");
}
?>
--FILE--
<?php
$php = getenv('TEST_PHP_EXECUTABLE');

// disallow console escape sequences that may break the output
putenv('TERM=VT100');

$codes = array();

$codes[1] = <<<EOT
echo 'Hello world';
exit
EOT;

$codes[] = <<<EOT
echo 'multine
single
quote';
exit
EOT;

$codes[] = <<<EOT
echo <<<HEREDOC
Here
comes
the
doc
HEREDOC;
EOT;

$codes[] = <<<EOT
if (0) {
    echo "I'm not there";
}
echo "Done";
EOT;

$codes[] = <<<EOT
function a_function_with_some_name() {
    echo "I was called!";
}
a_function_w	);
EOT;

foreach ($codes as $key => $code) {
    echo "\n--------------\nSnippet no. $key:\n--------------\n";
    $code = escapeshellarg($code);
    echo `echo $code | "$php" -a`, "\n";
}

echo "\nDone\n";
?>
--EXPECT--
--------------
Snippet no. 1:
--------------
Interactive shell

php > echo 'Hello world';
Hello world
php > exit


--------------
Snippet no. 2:
--------------
Interactive shell

php > echo 'multine
php ' single
php ' quote';
multine
single
quote
php > exit


--------------
Snippet no. 3:
--------------
Interactive shell

php > echo <<<HEREDOC
<<< > Here
<<< > comes
<<< > the
<<< > doc
<<< > HEREDOC;
Here
comes
the
doc
php > 

--------------
Snippet no. 4:
--------------
Interactive shell

php > if (0) {
php {     echo "I'm not there";
php { }
php > echo "Done";
Done
php > 

--------------
Snippet no. 5:
--------------
Interactive shell

php > function a_function_with_some_name() {
php {     echo "I was called!";
php { }
php > a_function_with_some_name();
I was called!
php > 

Done