mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
echo is not a function; neither is print; print, however, BEHAVES like a function -- #33968
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@192876 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
664127b478
commit
3c16b3eb40
1 changed files with 11 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.15 $ -->
|
||||
<!-- $Revision: 1.16 $ -->
|
||||
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.echo">
|
||||
<refnamediv>
|
||||
|
@ -18,9 +18,12 @@
|
|||
</simpara>
|
||||
<para>
|
||||
<function>echo</function> is not actually a function (it is a
|
||||
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.
|
||||
language construct), so you are not required to use parentheses
|
||||
with it. <function>echo</function> (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 <function>echo</function>, the parameters
|
||||
must not be enclosed within parentheses.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
|
@ -67,11 +70,13 @@ that the here document terminator must appear on a
|
|||
line with just a semicolon. no extra whitespace!
|
||||
END;
|
||||
|
||||
// Because echo is not a function, following code is invalid.
|
||||
// Because echo does not behave like 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
|
||||
($some_var) ? print 'true' : print 'false'; // print is also a construct, but
|
||||
// it behaves like a function, so
|
||||
// it may be used in this context.
|
||||
echo $some_var ? 'true': 'false'; // changing the statement around
|
||||
?>
|
||||
]]>
|
||||
|
|
Loading…
Reference in a new issue