The first glimpse of the PHP3 introductory course

Source: Internet
Author: User
Tags current time php script string format



PHP3.0 statements can be easily inserted into HTML, which provides a convenient way to implement dynamic design. For example, if you want to add the current date to an HTML file, we can do this:
< html>
< head>
< Title>our PHP3.0 script</title>
< body>
< center> my first PHP3.0 script </center>

<?
/* the "<" above indicates that the PHP script starts here.
$today = Date ("y-m-d");
PRINT "< center> today is: $today .</center>";

# "?>" means the end of the script
?>
</body>


Assuming today's date is January 20, 2000, the following will be shown:

My first PHP3.0 script.

Today is: 2000-01-20

Looking at this script, here's a little summary:

1. All PHP3.0 statements must be in the "2. Comments can be added to the script. You can use "/*" and "* *" to annotate a paragraph, or use "#" in front of the line to comment out the row.

3. If you want to output the results on the screen, you need to use the print statement, the output of the content should be in double quotes (") enclosed."

4. Each PHP3.0 statement is separated by a semicolon (;) To end.

5. Any HTML statement in PRINT will be interpreted by the client browser to interpret the output.

6. Files containing PHP statements, only after the suffix *.php3 named (such as: MYPHPFILE.PHP3) can be identified by the PHP3.0 interpreter and processed accordingly.

7. The date () function is used as follows:

Syntax:: string date (string format, int timestamp);

This function can have two parameters, the timestamp parameter is optional, and if there is no timestamp argument, the current time is used. The function then returns the corresponding formatted time string according to the given format (given by the format parameter). In the above example, y-m-d the next year, month, day, each with a number. There are many forms of representation, specific reference to the PHP3.0 document.



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.