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