xref: /php-src/sapi/cli/tests/bug71624.phpt (revision dcc3255b)
1--TEST--
2Bug #61977 Test that -R properly sets argi and argn
3--SKIPIF--
4<?php
5include "skipif.inc";
6?>
7--FILE--
8<?php
9
10$php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
11
12$filename_txt = __DIR__ . DIRECTORY_SEPARATOR . "bug71624.test.txt";
13$filename_txt_escaped = escapeshellarg($filename_txt);
14
15$txt = 'foo
16test
17hello
18';
19
20file_put_contents($filename_txt, $txt);
21
22$test_args = ['$argi', '$argn'];
23foreach ($test_args as $test_arg) {
24    if (substr(PHP_OS, 0, 3) == 'WIN') {
25        var_dump(`type $filename_txt_escaped | $php -n -R "echo $test_arg . PHP_EOL;"`);
26    } else {
27        var_dump(`cat $filename_txt_escaped | $php -n -R 'echo $test_arg . PHP_EOL;'`);
28    }
29}
30
31@unlink($filename_txt);
32
33echo "Done\n";
34?>
35--EXPECT--
36string(6) "1
372
383
39"
40string(15) "foo
41test
42hello
43"
44Done
45