mirror of
https://github.com/php/doc-ja.git
synced 2026-03-27 08:32:09 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@327533 c90b9560-bf6c-de11-be94-00142212c4b1
176 lines
5.2 KiB
XML
176 lines
5.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 34593e90612e01553a6a3f6f765698344be89c3b Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka,mumumu -->
|
|
<refentry xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="function.echo">
|
|
<refnamediv>
|
|
<refname>echo</refname>
|
|
<refpurpose>1 つ以上の文字列を出力する</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<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>
|
|
<literal>echo</literal> は実際には関数ではありません
|
|
(言語構造です)。このため、使用する際に括弧は必要ありません。
|
|
(いくつかの他の言語構造と異なり) <literal>echo</literal>
|
|
は関数のように動作しません。そのため、
|
|
関数のコンテキスト中では常に使用することができません。
|
|
加えて、複数のパラメータを指定して <literal>echo</literal>
|
|
をコールしたい場合、括弧の中にパラメータを記述してはいけません。
|
|
</para>
|
|
<para>
|
|
<literal>echo</literal> には、開始タグの直後に等号を付ける短縮構文もあります。
|
|
この短縮構文は、PHP 5.4.0 より前のバージョンでは設定オプション<link
|
|
linkend="ini.short-open-tag">short_open_tag</link>
|
|
が有効な場合しか使えません。
|
|
<informalexample>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
I have <?=$foo?> foo.
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>arg1</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
出力したいパラメータ。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>...</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.void;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><literal>echo</literal> の例</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
|
|
|
|
// 配列を使用することもできます
|
|
$baz = array("value" => "foo");
|
|
|
|
echo "this is {$baz['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>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.language-construct;
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>print</function></member>
|
|
<member><function>printf</function></member>
|
|
<member><function>flush</function></member>
|
|
<member><link linkend="language.types.string.syntax.heredoc">ヒアドキュメント構文</link></member>
|
|
</simplelist>
|
|
</para>
|
|
</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:"~/.phpdoc/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
|
|
-->
|