1--TEST--
2Test print() function : basic functionality
3--FILE--
4<?php
5
6echo "*** Testing print() : basic functionality ***\n";
7
8echo "\n-- Iteration 1 --\n";
9print("Hello World");
10
11echo "\n-- Iteration 2 --\n";
12print "print() also works without parentheses.";
13
14echo "\n-- Iteration 3 --\n";
15print "This spans
16multiple lines. The newlines will be
17output as well";
18
19echo "\n-- Iteration 4 --\n";
20print "This also spans\nmultiple lines. The newlines will be\noutput as well.";
21
22echo "\n-- Iteration 5 --\n";
23print "escaping characters is done \"Like this\".";
24
25// You can use variables inside of a print statement
26$foo = "foobar";
27$bar = "barbaz";
28
29echo "\n-- Iteration 6 --\n";
30print "foo is $foo"; // foo is foobar
31
32// You can also use arrays
33$bar = array("value" => "foo");
34
35echo "\n-- Iteration 7 --\n";
36print "this is {$bar['value']} !"; // this is foo !
37
38// Using single quotes will print the variable name, not the value
39echo "\n-- Iteration 8 --\n";
40print 'foo is $foo'; // foo is $foo
41
42// If you are not using any other characters, you can just print variables
43echo "\n-- Iteration 9 --\n";
44print $foo;          // foobar
45
46echo "\n-- Iteration 10 --\n";
47$variable = "VARIABLE";
48print <<<END
49This uses the "here document" syntax to output
50multiple lines with $variable interpolation. Note
51that the here document terminator must appear on a
52line with just a semicolon no extra whitespace!\n
53END;
54?>
55--EXPECT--
56*** Testing print() : basic functionality ***
57
58-- Iteration 1 --
59Hello World
60-- Iteration 2 --
61print() also works without parentheses.
62-- Iteration 3 --
63This spans
64multiple lines. The newlines will be
65output as well
66-- Iteration 4 --
67This also spans
68multiple lines. The newlines will be
69output as well.
70-- Iteration 5 --
71escaping characters is done "Like this".
72-- Iteration 6 --
73foo is foobar
74-- Iteration 7 --
75this is foo !
76-- Iteration 8 --
77foo is $foo
78-- Iteration 9 --
79foobar
80-- Iteration 10 --
81This uses the "here document" syntax to output
82multiple lines with VARIABLE interpolation. Note
83that the here document terminator must appear on a
84line with just a semicolon no extra whitespace!
85