PHP and MySQL (2)

Source: Internet
Author: User
Tags php example
PHP and MySQL (2) Basic syntax and commands

For anyone who has used C, C ++, Java, JavaScript, Perl, or other languages from C, PHP syntax will make you very familiar. A PHP script contains a series of commands (statements) that the Web server must process in sequence. Like other languages mentioned above, PHP statements always end with a semicolon.

This is a typical PHP statement:

Echo ("This isTest! ");

This statement calls a built-in function called echo and passes it the following string: "This isTest! ". Built-in functions can be understood as "you can know how to do it without additional instructions on PHP. PHP has many built-in functions. we can use them to do many things, from sending e-mail to processing different types of data stored in the database. The echo function simply inserts the text passed to it into the current location of the HTML page. You can look at the following example:



Simple PHP Example


Test! ");?>



If you name this code as test. php (or test. php3, if your Web host has not. PHP file configured as a PHP script), and place it on your Web server, the browser will see this page:



Simple PHP Example


This isTest!



Note that contains the HTML identifier (And.

You may wonder why we should use brackets and quotation marks here. In PHP, quotation marks are used to mark the start and end of a string. Parentheses have a double effect. First, it indicates that echo is a function you want to call. Second, it indicates the start and end of the function parameter. Through parameters, you can direct your function to what to do. For the echo function, we only need to give it a string for display on the page, but we will see that some functions have several parameters (in this case, separate parameters with commas ). Even for functions without parameters, we still need brackets, but we do not have to enter anything in the brackets.

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.