PHP writing format description (required), php writing description required _ PHP Tutorial

Source: Internet
Author: User
Tags echo command php print
PHP writing format (mandatory). php writing details are mandatory. PHP writing format description (required). php writing details must start with an example. Start the editor, create a php file, and type the following code: phpecho Hello !; Name the file in PHP format (mandatory ).

Start with an example.

Start the editor, create a php file, and type the following code:

<? Php echo "Hello! ";?>

Name the file test. php and store it in the E: html directory.

Access the php file http: // 127.0.0.1/test. php in the address bar of the browser. the output result is as follows:

Hello! In this example, we use the echo command to output a string "Hello !".

From this example, we can see that:

• The PHP file or PHP code segment uses "<? Php, starting with "?>" End: php code in the middle

• Each instruction set ends with a; symbol

• The browser returns results after the PHP parser executes the php code. website viewers cannot view the original php file code.

Of course, to output standard html code, you can complete the above example:

    PHP testing      

<? Php echo "Hello! ";?>

It can be seen that PHP code can be mixed with XHTML code.

Echo is a PHP built-in command used to output one or more strings. similar to echo, there is print.

Next we will introduce the php output functions.

PHP echo and print statements

Difference between echo and print:

• Echo-one or more strings can be output.

• Print-only one string can be output, and the total return value is 1

Tip: The echo output speed is faster than print. echo does not return a value. print has a return value of 1.

PHP echo statement

Echo is a language structure. it can be used without parentheses, echo or echo ().

1. display strings

The following example demonstrates how to use the echo command to output a string (a string can contain HTML tags ):

<?php echo "PHP is fun!"; echo "Hello world!
"; echo "I'm about to learn PHP!
"; echo "This", " string", " was", " made", " with multiple parameters."; ?>

2. display variables

The following example demonstrates how to use the echo command to output variables and strings.

<?php $txt1="Learn PHP"; $txt2="manongjc.com"; $cars=array("Volvo","BMW","Toyota");  echo $txt1; echo "
"; echo "Study PHP at $txt2"; echo "My car is a {$cars[0]}"; ?>

PHP print statement

Print is also a language structure, which can be parentheses or not ().

1. display strings

The following example demonstrates how to use the print command to output a string (a string can contain HTML tags ):

<?php print "PHP is fun!"; print "Hello world!
"; print "I'm about to learn PHP!"; ?>

2. display variables

The following example demonstrates how to use the print command to output variables and strings:

<?php $txt1="Learn PHP"; $txt2="manongjc.com"; $cars=array("Volvo","BMW","Toyota");  print $txt1; print "
"; print "Study PHP at $txt2"; print "My car is a {$cars[0]}"; ?>

The above PHP writing format (mandatory) is all the content shared by the editor. I hope you can give us a reference and support the help house.

For more information about php writing, refer to an example. Start the editor, create a php file, and type the following code: php echo "Hello! "; Name the file...

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.