echo Simple usage in PHP

Source: Internet
Author: User

Beginners, by echo grammar puzzles, view, ask you big God guidance!!!

The manual writes echo- output One or more strings, while strings have single quotes, double quotes, and delimiters.

Single quotes only output the characters themselves, and the double quotes will output the variables, which are detailed in the manual.

<?php
echo "Hello World";

echo "This spans
multiple lines. The newlines would be
output as well ";
//
echo "This spans\nmultiple lines. The newlines would be\noutput as well. ";
//
echo "Escaping characters is do \" like This\ ".";

//You can use variables in echo statements
$foo = "Foobar";
$bar = "Barbaz";

echo "Foo is $foo";//foo is foobar

can also use arrays
$baz = Array ("value" = "foo");

echo "This is {$baz [' value ']}!",//This is Foo!

Use single quotation marks to print variable names instead of values
Echo ' foo is $foo ';//foo are $foo

If you do not use any other characters, you can return only the variable
Echo $foo; Foobar
echo $foo, $bar; Foobarbarbaz

Strings can be passed or concatenated as multiple parameters individually and passed as a parameter
echo ' This ', ' string ', ' is ', ' made ', ' with multiple parameters ', CHR;
echo ' this '. ' String '. ' was '. ' Made '. ' with concatenation. ' "\ n";
//
Echo <<<end
This uses the ' Here Document ' syntax to output
multiple lines with $variable interpolation. Note
The here document Terminator must appear on a
Line with just a semicolon. No extra whitespace!
END;

Because the echo is not like a function, the following code is invalid.
($some _var)? Echo ' true ': echo ' false ';

However, the following example will work:
($some _var)? print ' true ': print ' false ';//print is also a construct, but
//It behaves like a function, so
//It is used in this context.
echo $some _var? ' True ': ' false '; Changing the statement around
?>

I wrote the code myself.

echo "{$match [0][0]}". " \ n "." {$match [0][1]} "." \ n "." {$match [0][2]} "." \ n "." {$match [0][3]} "." \ n "." {$match [0][4]} ";

echo "{$match [0][0]}", "\ n", "{$match [0][1]}", "\ n", "{$match [0][2]}", "\ n", "{$match [0][3]}", "\ n", "{$match [0][4]}";

It can be seen that different character-descriptor variables may be used in English. |, separated, with an escape character, so that each output an array on a line, to output an array, it is best to include braces.

can only be output as a continuous string

Echo ' wo Zai zhe '. \ n "." Huanhang ';

echo Simple usage in PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.