PHP writing format detailed (must see), PHP writing detailed must see _php tutorial

Source: Internet
Author: User
Tags echo command php print

PHP writing format detailed (must see), PHP writing detailed must see


Start with an example.

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

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

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

How are you doing! In this example, we output a string with the echo command "Hello!" ”。

As you can see from this example:

php file or PHP snippet begins with "<?php" and ends with "?>" with PHP code in the middle

• Each instruction set to; End of symbol

• The browser gets the PHP parser after executing the PHP code results, the site viewer can not see the original PHP file code

Of course, to output the standard HTML code, the above example can be perfected as:

    PHP Test      

<?php echo "Hello!" ";?>

The PHP code can be seen to be mixed with XHTML code.

Echo is a PHP built-in instruction for outputting 1 or more strings, similar to echo and print.

Below we introduce the output function of PHP.

PHP Echo and Print statements

Echo and Print differences:

echo-can output one or more strings

print-allows only one string to be output, with a total of 1 return values

Tip: The echo output is faster than print, ECHO has no return value, and print has a return value of 1.

PHP Echo Statement

Echo is a language structure that can be used without parentheses or parentheses: Echo or Echo ().

1. Display string

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

<?php echo "

PHP is fun!

"; echo "Hello world!
"; echo "I ' m about to learn php!

2. Display variables

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

<?php $txt 1= "Learn PHP"; $txt 2= "manongjc.com"; $cars =array ("Volvo", "BMW", "Toyota");  echo $txt 1; echo "

PHP Print Statement

Print is also a language structure, you can use parentheses, or you can use no parentheses: Print or print ().

1. Display string

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

<?php print "

PHP is fun!

"; Print "Hello world!

2. Display variables

The following example shows how to use the Print command to output variables and strings:

<?php $txt 1= "Learn PHP"; $txt 2= "manongjc.com"; $cars =array ("Volvo", "BMW", "Toyota");  Print $txt 1; Print "

The above-mentioned PHP writing format (must see) is a small part of the whole content to share to everyone, hope to give you a reference, but also hope that we have a lot of support to help the home.

http://www.bkjia.com/PHPjc/1133104.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133104.html techarticle PHP Writing format detailed (must see), PHP written in detail must look at the beginning of 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.