April 2026
Intermediate
1009 pages
34h 15m
English
To really get started with PHP, you need to be able to test how the syntax and programming constructs work. To do this, you should be able to output data. PHP has two language constructs[ 28 ] for output:
The echo statement:
<?php echo "output"; ?>
The print statement:
<?php print "Output"; ?>
The two statements differ in that echo simply outputs what has been passed, whereas print returns a return value.[ 29 ]
This return value can be written to a variable (Section 4.3) and can be saved. The value is 1 if the output has worked.
<?php $t = print "Output"; echo $t;?>
Listing 4.3 Return Value of "print" ("print.php")
Listing 4.3 prints the line:
Output
In practice, the return value is rarely used.
Read now
Unlock full access