Basic PHP tutorial syntax

Source: Internet
Author: User

PHP script block with <? Start with PHP and start with?> End. You can place PHP script blocks anywhere in the document.
Of course, you can use <? And?> To start and end the script block.
However, to achieve the best compatibility, we recommend that you use the standard form (<? PHP), rather than the abbreviated form. CopyCode The Code is as follows: <? PHP
?>

PHP files usually contain HTML tags, like an HTML file and some PHP script code.
Below, we provide a simple PHP script, which can output the text "Hello World" to the browser ":Copy codeThe Code is as follows: <HTML>
<Body>
<? PHP
Echo "this is Php tutorial network! ";
?>
</Body>
</Html>

each line of code in PHP must end with a semicolon. A semicolon is a Separator Used to differentiate the instruction set.
there are two basic commands for outputting text through PHP: ECHO and print. In the above example, we use the echo statement to output the text.
comments in PHP
in PHP, we use // to write single-line comments, or use/* and */to write large comments. copy Code the code is as follows:

// This is a comment
/*
This is a big comment,
you can comment multiple lines
*/
echo "test string1";
echo "
"; // Add "
" Here to generate a new line on the web page, that is, line feed
echo "
";
// echo "test string2
";
// echo "test string3
";
echo "test string4
";
?>

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.