PHP Full Stack Development (V): PHP Learning (2. Echo and print output, array)

Source: Internet
Author: User

There are two basic output statements in PHP, Echo and print

What's the difference between these two things?

echo can output one or more characters at a time:

Echo "This is a", "string,", "used", "multiple", "parameter." ";

Like this, there is no problem with the output.

The result of the output is: This is a string that uses more than one parameter

Then echo's output is not wrapped, and if you need to wrap it, you can add it later <br>

Echo "This is a", "string,", "used", "multiple", "parameter." <br> ";

You can also add a variable output to the middle of a string.

$x=5; Echo $x, "a", "parameter." <br> ";

is still more convenient.

Can also be like this, but $x must add a space behind, or will error

$x=5; Echo "This is a", "string,", "used", "$x ", "parameter." <br> ";

Array

$cars=array("Volvo", "BMW", "Toyota");

You can create an array like this, using the count () function to return the number of elements in the array

Echo Count ($cars);

You can use the following methods to facilitate an array:

$dog=array("xxx", "yyyy", 5,3.23, "Xxd"); $lang=count($dog);  for ($x= 0; $x<$lang; $x+ +)    {echo$dog[$x], "<br>";}

Good trouble, it's not as simple as python.

PHP Full Stack Development (V): PHP Learning (2. Echo and print output, array)

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.