Php Getting Started Tutorial (7) PHP functions

Source: Internet
Author: User
Php Getting Started Tutorial (7) PHP functions

  1. Function writeMyName ()
  2. // Bbs.it-home.org
  3. Echo "jeremyLin ";
  4. }
  5. WriteMyName ();
  6. ?>

2. function-adding a parameter the first function is a very simple function. It can only output one static string. You can add parameters to add more functions to a function. The parameter is similar to a variable. Example:

  1. Function writeMyName ($ fname)
  2. // Bbs.it-home.org
  3. Echo $ fname. "jeremy.
    ";
  4. }
  5. Echo "My name is ";
  6. WriteMyName ("lin ");
  7. Echo "My name is ";
  8. WriteMyName ("kobe ");
  9. Echo "My name is ";
  10. WriteMyName ("John ");
  11. ?>

3. function-return value functions can also be used to return values.

  1. Function add ($ x, $ y)
  2. {
  3. $ Total = $ x + $ y;
  4. Return $ total;
  5. }
  6. Echo "4 + 26 =". add (4, 26 );
  7. ?>

Output: 4 + 26 = 30

>>> View more php tutorials <

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.