(PHP 4, PHP 5, PHP 7)
echo — ���һ�������ַ���
$arg1
[, string $...
] ) : void������в��������ỻ�С�
echo ����һ������������һ�����Խṹ���� ����㲻һ��Ҫʹ��С������ָ�������������ţ�˫���Ŷ����ԡ� echo �������������Թ��죩�����ֵ���һ�������� ���Բ�������ʹ��һ�������������ġ� ���⣬��������echo ���ݶ�������� ��ô�Ͳ���ʹ��С���š�
echo Ҳ��һ������÷���������ڴ��ǰֱ����һ���Ⱥš��� PHP 5.4.0 ֮ǰ��������php.ini �������� short_open_tag ����Ч��
I have <?=$foo?> foo.
�� print ����Ҫ�IJ�֮ͬ���ǣ� echo ���ܲ����б�����û�з���ֵ��
arg1
Ҫ����IJ���
...
û�з���ֵ��
Example #1 echo ����
<?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\".";
// You can use variables inside of an echo statement
$foo = "foobar";
$bar = "barbaz";
echo "foo is $foo"; // foo is foobar
// You can also use arrays
$baz = array("value" => "foo");
echo "this is {$baz['value']} !"; // this is foo !
// 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
// Strings can either be passed individually as multiple arguments or
// concatenated together and passed as a single argument
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;
// Because echo does not behave like a function, the following code is invalid.
($some_var) ? echo 'true' : echo 'false';
// However, the following examples will work:
($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
?>
Note: ��Ϊ��һ�����Թ�����������һ�����������ܱ� �ɱ亯�� ���á�
��� echo ��ƴ���ַ������ԣ����ݶ�������ȽϺã����ǵ��� PHP �������������"."�������ȼ��� ����������������ҪԲ���ű�֤���ȼ���
<?php
echo "Sum: ", 1 + 2;
echo "Hello ", isset($name) ? $name : "John Doe", "!";
�����ƴ�ӵģ�����ڼӺź���ĿԪ����������������"."�����и������ȼ���Ϊ����ȷ�ԣ�����ʹ��Բ���ţ�
<?php
echo 'Sum: ' . (1 + 2);
echo 'Hello ' . (isset($name) ? $name : 'John Doe') . '!';