1
0
mirror of https://github.com/php/doc-ja.git synced 2026-03-31 11:32:18 +02:00
Files
archived-doc-ja/reference/strings/functions/echo.xml
Hideyuki Shimooka fc07cb6167 translation updated
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@194041 c90b9560-bf6c-de11-be94-00142212c4b1
2005-08-20 13:01:00 +00:00

136 lines
4.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.7 $ -->
<!-- EN-Revision: 1.17 Maintainer: hirokawa Status: ready -->
<!-- CREDITS: shimooka -->
<refentry id="function.echo">
<refnamediv>
<refname>echo</refname>
<refpurpose>1つ以上の文字列を出力する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>void</type><methodname>echo</methodname>
<methodparam><type>string</type><parameter>arg1</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>...</parameter></methodparam>
</methodsynopsis>
<simpara>
この関数は、すべてのパラメータを出力します。
</simpara>
<para>
<function>echo</function> は実際には関数ではありません
(言語構造です) 。このため、使用する際に括弧は必要ありません。
(いくつかの他の言語構造と異なり) <function>echo</function>
は関数のように動作しません。そのため、
常に関数のコンテキスト中で使用することはできません。
加えて、複数のパラメータを指定して <function>echo</function>
をコールしたい場合、括弧の中にパラメータを記述するべきではありません。
</para>
<para>
<example>
<title><function>echo</function> の例</title>
<programlisting role="php">
<![CDATA[
<?php
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.";
echo "escaping characters is done \"Like this\"."
// echo 命令の中で変数を使用することが可能です
$foo = "foobar";
$bar = "barbaz";
echo "foo is $foo"; // foo is foobar
// 配列を使用数こともできます
$bar = array("value" => "foo");
echo "this is {$bar['value']} !"; // this is foo !
// 値ではなく変数名を出力するシングルクオートを使用する。
echo 'foo is $foo'; // foo is $foo
// 他の文字を全く使用しない場合、echo 変数を使用可能です。
echo $foo; // foobar
echo $foo,$bar; // foobarbarbaz
// 複数のパラメータを結合してechoに渡そうとする人もいます
echo 'This ', 'string ', 'was ', 'made ', 'with multiple parameters.', chr(10);
echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n";
echo <<<END
This uses the "here document" syntax to output
multiple lines with $variable interpolation. Note
that the here document terminator must appear on a
line with just a semicolon. no extra whitespace!
END;
// echo は関数のように動作しないので、以下のコードは正しくありません
($some_var) ? echo 'true' : echo 'false';
// しかし、次の例は動作します。
($some_var) ? print 'true' : print 'false'; // print も言語構造ですが、
// 関数のように動作します。なので、
// このコンテキスト中で使用できます
echo $some_var ? 'true': 'false'; // 命令を変更
?>
]]>
</programlisting>
</example>
</para>
<para>
<function>echo</function> には、開始タグの直後に等号を付ける
短縮構文もあります。この短縮構文は、設定オプション<link
linkend="ini.short-open-tag">short_open_tag</link>が有効な
場合のみ使用可能です。
<informalexample>
<programlisting role="php">
<![CDATA[
I have <?=$foo?> foo.
]]>
</programlisting>
</informalexample>
</para>
<simpara>
<function>print</function><function>echo</function>の違いに関する
簡単な議論については、FAQTs Knowledge Base Article:
<ulink url="&url.echo-print;">&url.echo-print;</ulink> を参照してください。
</simpara>
&note.language-construct;
<simpara>
<function>print</function>,
<function>printf</function>,
<function>flush</function> も参照ください。
</simpara>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->