cvs: phpdoc /en/functions strings.xml

From: Date: Wed, 21 Mar 2001 05:59:44 +0000
Subject: cvs: phpdoc /en/functions strings.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969334767@lists.php.net to get a copy of this message
ronabop Tue Mar 20 21:59:44 2001 EDT Modified files: /phpdoc/en/functions strings.xml Log: Adding more echo examples per errata. Index: phpdoc/en/functions/strings.xml diff -u phpdoc/en/functions/strings.xml:1.78 phpdoc/en/functions/strings.xml:1.79 --- phpdoc/en/functions/strings.xml:1.78 Sat Mar 10 10:51:47 2001 +++ phpdoc/en/functions/strings.xml Tue Mar 20 21:59:43 2001 @@ -489,10 +489,12 @@ <para> <function>Echo</function> is not actually a function (it is a language construct) so you are not required to use parantheses - with it. + with it. In fact, if you want to pass more than one parameter + to echo, you must not enclose the parameters within parentheses. <example> - <title><function>Echo</function> example</title> + <title><function>Echo</function> examples</title> <programlisting role="php"> +&lt;?php echo "Hello World"; echo "This spans @@ -500,15 +502,41 @@ output as well"; echo "This spans\nmultiple lines. The newlines will be\noutput as well."; + +echo "escaping characters is done \"Like this\"." + +//You can use variables inside of an echo statement +$foo = "foobar"; +$bar = "barbaz"; + +echo "foo is $foo"; // foo is foobar + +// 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 + +// because echo is not a function, following code is invalid. +($some_var) ? echo('true'): echo('false'); + +// However, the following examples will work: +($some_var) ? print('true'): print('false'); // print is a function +echo ($some_var) ? 'true': 'false'; // changing the statement around +?> </programlisting> </example> + </para> + <para> + <function>Echo</function> also has a shortcut syntax, where you + can immediately follow the opening tag with an equals sign. + <informalexample> + <programlisting role="php"> +I have &lt;?=$foo?> foo. + </programlisting> + </informalexample> </para> - <note> - <para> - In fact, if you want to pass more than one parameter to echo, - you must not enclose the parameters within parentheses. - </para> - </note> <simpara> See also: <function>print</function>,

« previous php.doc (#969334767) next »