PHP Tutorial Basic Syntax _php basics

Source: Internet
Author: User
PHP script blocks start with <?php and end with?>. You can place PHP script blocks anywhere in the document.
Of course, on a server that supports shorthand, you can use the. and?> to start and end script blocks.
However, in order to achieve the best compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form.
Copy Code code as follows:

<?php
?>

PHP files usually contain HTML tags, like an HTML file, and some PHP scripting code.
Below, we provide a simple PHP script that can output text to the browser "Hello World":
Copy Code code as follows:


<body>
<?php
echo "This is the PHP tutorial web!";
?>
</body>


Each line of code in PHP must end with a semicolon. A semicolon is a delimiter used to differentiate a set of instructions.
There are two basic instructions for outputting text through PHP: Echo and print. In the example above, we used 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 comment blocks.
Copy Code code as follows:


<body>
<?php
This is a note
/*
This is the big note,
You can annotate multiple lines
*/
echo "Test string1";
echo "<br/>"; Add "<br/>" here to generate a new line on a Web page that wraps
echo "<br/>";
echo "Test string2<br/>";
echo "Test string3<br/>";
echo "Test string4<br/>";
?>
</body>

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.