★ wanayoo — archive 1999 http://www.php.net/manual/it/function.echo.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Strings
Quick Reference
English version of this pageGerman version of this pageJapanese version of this pageFrench version of this pageHungarian version of this page
Strings
* AddCSlashes
* AddSlashes
* bin2hex
* Chop
* Chr
* chunk_split
* convert_cyr_string
* count_chars
* crypt
* echo
* explode
* flush
* get_html_translation_table
* get_meta_tags
* htmlentities
* htmlspecialchars
* implode
* join
* ltrim
* md5
* Metaphone
* nl2br
* Ord
* parse_str
* print
* printf
* quoted_printable_decode
* QuoteMeta
* rawurldecode
* rawurlencode
* setlocale
* similar_text
* soundex
* sprintf
* strcasecmp
* strchr
* strcmp
* strcspn
* strip_tags
* StripCSlashes
* StripSlashes
* stristr
* strlen
* strpos
* strrchr
* str_repeat
* strrev
* strrpos
* strspn
* strstr
* strtok
* strtolower
* strtoupper
* str_replace
* strtr
* substr
* substr_replace
* trim
* ucfirst
* ucwords
Manual: echo
View the source code for this pageSearch the site



Previous page
 crypt
 Updated
Sun, 06 Aug 2000
explode 
Next page


echo

(unknown)

echo -- Output one or more strings.

Description

echo (string arg1, string [argn]...)

Outputs all parameters.

Echo() is not actually a function (it is a language construct) so you are not required to use parantheses with it.

Esempio 1. Echo() example


echo "Hello World";

echo "This spans
multiple lines. The newlines will be 
output as well";

echo "This spans\nmultiple lines. The newlines will be\noutput as well.";
      

Nota: In fact, if you want to pass more than one parameter to echo, you must not enclose the parameters within parentheses.

See also: print(), printf(), and flush().


User Contributed Notes: echo


slanders@mobsec.com
29-Apr-1999 10:11
To echo an Array of Arrays:

A two-dimensional array is one array nested inside of another
array. I assigned the two-dimensional array using the following format:



$ref = array(

"10" => array(1,2),

"11" => array(3,4),

"12" => array("john", "fred")

);



The array $ref contains the arrays $10, $11, $12 as the three
elements. The nested arrays need to be named by sequential numbers
because when called, one references their name, not their element number
within the outer array $ref. In order to print these nested arrays, I used a
double for loop and an echo statement. This is done in the following manner:



for($i = 10; $i <= 12; $i++) {

for($j = 0; $j <= 1; $j++) {

echo $ref[$i][$j] . "\n";

}

}



This will print 1234johnfred to the screen.



david@audiogalaxy.com
18-Feb-2000 01:09
As alluded to in sessions, <?= $foo ?> appears to be a shortcut for <? echo($foo); ?> analogous <%= $foo %>.


ckernan@tibus.net
18-May-2000 03:51
Use a period to concatenate text and variables e.g.

<?
echo "this color is " . $color . ", my favorite color";
?>



philip@theprojects.org
29-Jun-2000 02:48
To use quotes, use backslashes like this:


echo "i want to \"quote\" stuff"


a useful string tutorial is :


http://www.zend.com/zend/tut/using-strings.php




monman_us@yahoo.com
08-Jul-2000 04:51
To echo text and variables on one line, this seems like the easiest way:

$x = "This works! I've tried it";
echo "x is: $x";

You can also include that straight into the HTML, like this:
<html><body>
<?php
$x = "This also works!";
?>
x is: $x
</body></html>



powerlord@vgmusic.com
28-Jul-2000 05:53
Multiple word values require quotes around them. So, in a form try this:


<input type="hidden" value="<?php echo $book; ?>">


If it's in a URL, try this:


&title=<?php echo rawurlencode($book); ?>)




dewcansamc@excite.com
03-Aug-2000 08:22
quick note if you want to substitute the '=' for echo. The '=' must be connected to the open Php tag. Anything else won't work.
this works:
<?=$str;?>
this doesn't:
<? = $str; ?>
also use this alone. Multiple echos use 'echo'
alright i know that this seems trivial but, i sure could NOT find this documented anywhere else



 About Notes


Previous page
 crypt
 Updated
Sun, 06 Aug 2000
explode 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.