Implement 99 multiplication table code using PHP custom functions

Source: Internet
Author: User
In the PHP custom function creation definition is very simple, we just use function space followed by the functions of the name can be, the intermediate function can have parameters and related content, specifically as follows.

Using a custom function to implement the 99 multiplication table, a function is a block of code that can be executed at any time when needed.

To create a PHP function:
All functions use the keyword "function ()" to start
Named function – the name of the function should indicate its function. The function name begins with a letter or underscore.
Add "{" – the section after the opening curly brace is the code of the function.
inserting function code
Add a "}" – The function ends by closing the curly braces.
Example
A simple function that can output my name when it is called:


Using PHP functions
Now, we're going to use this function in our PHP script:


The output of the above code:

Hello world!
My name is David Yang.
That's right, David Yang is my name

Let's write a 99 multiplication table using a function.

<php?/** * 9*9 Multiplication Table * string fun_99 (int $start =1, int $end =1,bool $sort =true) * $start starting number must be between 1-9 and must be an integer * $end end value Must be between 1-9 and must be an integer and be greater than $start * $sort to indicate a sort, true to indicate a positive order, and false to indicate reverse */echo "

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.