Getting Started with PHP and MySQL (2)

Source: Internet
Author: User
Tags getting started with php php example
Basic syntax and commands

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

This is a typical PHP statement:

Echo ("This is a test!");

This statement invokes a built-in function called Echo and passes it to such a string: "This is a test!" ”。 Built-in functions you can understand the "do not need another explanation of PHP can know how to do" thing. PHP has a lot of built-in functions that we can use to do a lot of things, from sending e-mails to processing the different types of data stored in the database are their jurisdictions. The Echo function simply inserts the text passed to it into the current position of the HTML page. You can take a look at the following example:



Simple PHP Example


Test! ");? >



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



Simple PHP Example


This is a test!



Note that all text including the HTML identifier ( and ) is displayed correctly.

You may wonder why we use parentheses and quotes here. Quotation marks are used in PHP to mark the beginning and end of a string. Parentheses have a double effect, first of all, it indicates that echo is a function you want to call, and secondly, it marks the beginning and end of the function's arguments. Through the parameters, you can direct your function to what to do. For the echo function, we just need to give it a string to display on the page, but we'll see that some functions have several parameters (in this case, we separate each parameter with commas). Even for functions that have no arguments, we need to have parentheses, except that we don't have to enter anything in the middle of the parentheses.

  • Related Article

    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.