< All PHP topicsPHP (2)Perl (1)Java (2)

Standard Out (STDOUT)

Standard out, also known as printing to screen, is the most basic method used to output data from an application.

This topic is very basic and overlaps String handling

PHP:

PHP uses the echo command to output on Standard Out.

echo in PHP

Last updated at 03:43 PM on Sunday 15th February, 2009 by Isaac Turner


Standard out is done with the echo[uk.php.net] command in PHP

Echo is not a function in PHP, rather it is a 'language construct'. [a|http://uk.php.net/manual/en/function.print.php]Print()[/a] is a function equivalent Print()[uk.php.net] is a function equivalent of echo, allowing it to be used in complex expressions.

Double quotes

<?
$text 
"Hello";
echo 
"$text World!
And multiline"
;
?>

Out:
Hello World!
And multiline

Single quotes

<?
$text 
"Hello";
echo 
'$text World!
And multiline'
;
?>

Out:
$text World!
And multiline

Or

<?
echo <<<EOM
$text World!
and multiline
EOM;
?>

Out:
Hello World!
And multiline

Comments (0)

Capture Standard Out

Last updated at 01:23 PM on Wednesday 8th August, 2007 by Administrator


<?
ob_start
();

echo 
"Hello!";

$text ob_get_contents();
ob_end_clean();
?>

Comments (0)