Below is the text of the page https://ua2.php.net/echo stored 2009-10-05 by archive.org.ua. The original page over time could change. View as original html

PHP: echo - Manual

[/] downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net s earch for in the all php.net sites this mirror only function list online documentation bug database Site News Archive All Changelogs just pear.php.net just pecl.php.net just talks.php.net general mailing list developer mailing list documentation mailing list PHP Manual Function Reference Text Processing Strings String Functions addcslashes addslashes bin2hex chop chr chunk_ split convert_ cyr_ string convert_ uudecode convert_ uuencode count_ chars crc32 crypt echo explode fprintf get_ html_ translation_ table hebrev hebrevc html_ entity_ decode htmlentities htmlspecialchars_ decode htmlspecialchars implode join lcfirst levenshtein localeconv ltrim md5_ file md5 metaphone money_ format nl_ langinfo nl2br number_ format ord parse_ str print printf quoted_ printable_ decode quoted_ printable_ encode quotemeta rtrim setlocale sha1_ file sha1 similar_ text soundex sprintf sscanf str_ getcsv str_ ireplace str_ pad str_ repeat str_ replace str_ rot13 str_ shuffle str_ split str_ word_ count strcasecmp strchr strcmp strcoll strcspn strip_ tags stripcslashes stripos stripslashes stristr strlen strnatcasecmp strnatcmp strncasecmp strncmp strpbrk strpos strrchr strrev strripos strrpos strspn strstr strtok strtolower strtoupper strtr substr_ compare substr_ count substr_ replace substr trim ucfirst ucwords vfprintf vprintf vsprintf wordwrap explode crypt Last updated: Fri, 02 Oct 2009 view this page in Bulgarian Brazilian Portuguese French German Japanese Korean Polish Romanian Turkish Other echo (PHP 4, PHP 5) echo — Output one or more strings Description void echo ( string $arg1 [, string $... ] ) Outputs all parameters. echo() is not actually a function (it is a language construct), so you are not required to use parentheses with it. echo() (unlike some other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass more than one parameter to echo() , the parameters must not be enclosed within parentheses. echo() also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. This short syntax only works with the short_open_tag configuration setting enabled. I have foo. Parameters arg1 The parameter to output. ... Return Values No value is returned. Examples Example #1 echo() examples "foo" ); echo "this is { $baz [ 'value' ]} !" ; // this is foo ! // Using single quotes will print the variable name, not the value echo 'foo is $foo' ; // foo is $foo // If you are not using any other characters, you can just echo variables echo $foo ; // foobar echo $foo , $bar ; // foobarbarbaz // Some people prefer passing multiple parameters to echo over concatenation. echo 'This ' , 'string ' , 'was ' , 'made ' , 'with multiple parameters.' , chr ( 10 ); echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n" ; echo << Notes For a short discussion about the differences between print() and echo() , see this FAQTs Knowledge Base Article: » http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40 Note : Because this is a language construct and not a function, it cannot be called using variable functions See Also print() - Output a string printf() - Output a formatted string flush() - Flush the output buffer Heredoc syntax explode crypt Last updated: Fri, 02 Oct 2009 add a note User Contributed Notes echo Jakob Thomsen 23-Nov-2008 02:23 A way to color your echo output is to use shell_exec and the echo command (this only works on Linux/bash) in the following way: See http://wiki.archlinux.org/index.php/Color_Bash_Prompt for more colors and other options. sandaimespaceman at gmail dot com 01-Sep-2008 06:25 Outputting \n won't generate a line break in the browser,
is required for line break. Also, will like first linesecond line because you didn't insert spaces/line breaks. the echo function can also be written like nikolaas dot mennega at links dot com dot au 01-Nov-2007 07:04 hemanman at gmail dot com, the problem is that func() doesn't actually return a value (string or otherwise), so the result of echoing func() is null. With the comma version, each argument is evaluated and echoed in turn: first the literal string (simple), then func(). Evaluating a function call obviously calls the function (and in this case executes its own internal echo), and the result (null) is then echoed accordingly. So we end up with "outside func() within func()" as we would expect. Thus: effectively becomes: The dot version is different: there's only one argument here, and it has to be fully evaluated before it can be echoed as requested. So we start at the beginning again: a literal string, no problem, then a concatenator, then a function call. Obviously the function call has to be evaluated before the result can be concatenated with the literal string, and THAT has to happen BEFORE we can complete the echo command. But evaluating func() produces its own call to echo, which promptly gets executed. Thus: effectively becomes: Jason Carlson - SiteSanity 16-May-2005 05:28 In response to Ryan's post with his echobig() function, using str_split wastes memory resources for what you are doing. If all you want to do is echo smaller chunks of a large string, I found the following code to perform better and it will work in PHP versions 3+ ryan at wonko dot com 27-Feb-2005 08:56 Due to the way TCP/IP packets are buffered, using echo to send large strings to the client may cause a severe performance hit. Sometimes it can add as much as an entire second to the processing time of the script. This even happens when output buffering is used. If you need to echo a large string, break it into smaller chunks first and then echo each chunk. The following function will do the trick in PHP5: zombie)at(localm)dot(org) 25-Jan-2003 07:26 [Ed. Note: During normal execution, the buffer (where echo's arguments go) is not flushed (sent) after each write to the buffer. To do that you'd need to use the flush() function, and even that may not cause the data to be sent, depending on your web server.] Echo is an i/o process and i/o processes are typically time consuming. For the longest time i have been outputting content by echoing as i get the data to output. Therefore i might have hundreds of echoes in my document. Recently, i have switched to concatenating all my string output together and then just doing one echo at the end. This organizes the code more, and i do believe cuts down on a bit of time. Likewise, i benchmark all my pages and echo seems to influence this as well. At the top of the page i get the micro time, and at the end i figure out how long the page took to process. With the old method of "echo as you go" the processing time seemed to be dependent on the user's net connection as well as the servers processing speed. This was probably due to how echo works and the sending of packets of info back and forth to the user. One an one script i was getting .0004 secs on a cable modem, and a friend of mine in on dialup was getting .2 secs. Finally, to test that echo is slow; I built strings of XML and XSLT and used the PHP sablotron functions to do a transformation and return a new string. I then echoed the string. Before the echo, the process time was around .025 seconds and .4 after the echo. So if you are big into getting the actual processing time of your scripts, don't include echoes since they seem to be user dependent. Note that this is just my experience and it could be a fluke. add a note explode crypt Last updated: Fri, 02 Oct 2009 show source | credits | sitemap | contact | advertising | mirror sites Copyright © 2001-2009 The PHP Group All rights reserved. This mirror generously provided by: Max Khaikin Last updated: Mon Oct 5 00:21:18 2009 UTC