trying to explain some consequences of the differences between

language constructs "echo" and "print"


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@71976 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Hartmut Holzgraefe 2002-03-05 11:25:00 +00:00
parent 6e984af0c5
commit bb0af361c5
2 changed files with 14 additions and 8 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.164 $ -->
<!-- $Revision: 1.165 $ -->
<reference id="ref.strings">
<title>String functions</title>
<titleabbrev>Strings</titleabbrev>
@ -518,6 +518,9 @@ if (crypt($user_input,$password) == $password) {
language construct) so you are not required to use parentheses
with it. In fact, if you want to pass more than one parameter
to echo, you must not enclose the parameters within parentheses.
It is not possible to use <function>echo</function> in a
<link linkend="functions.variable-functions">variable function</link>
context, but you can use <function>print</function> instead.
<example>
<title><function>echo</function> examples</title>
<programlisting role="php">
@ -1657,9 +1660,11 @@ echo $second[1]; /* prints "another" */
Outputs <parameter>arg</parameter>. &return.success;
</simpara>
<para>
<function>print</function> is not actually a function (it is a
<function>print</function> is not actually a real function (it is a
language construct) so you are not required to use parentheses
with it.
with it. But <function>print</function>, opposed to
<function>echo</function>, can be called using a
<link linkend="functions.variable-functions">variable function</link>.
</para>
<example>
<title><function>print</function> examples</title>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.24 $ -->
<!-- $Revision: 1.25 $ -->
<chapter id="functions">
<title>Functions</title>
@ -332,11 +332,12 @@ $newref =& returns_reference();
be used to implement callbacks, function tables, and so forth.
</para>
<para>
Variable functions won't work with language constructs such as
Variable functions won't work with language constructs other
than <function>print</function>, such as
<function>echo</function>, <function>unset</function>,
<function>isset</function> and <function>empty</function>. This is
one of the major differences between PHP functions and language
constructs.
<function>isset</function> and <function>empty</function>.
This is one of the major differences between PHP functions
and languageconstructs.
</para>
<para>
<example>