The function declaration of the Photoshop Learning Web PHP Learning Note

Source: Internet
Author: User
Copy CodeThe code is as follows:


/* Function Definition:
* 1. The function is a named
* 2. Separate Code Snippets
* 3. Functions perform specific tasks
* 4. And can return a value to the program that called it
*
* Advantages of the function:
* 1. Improve the reusability of the program
* 2. Improve the maintainability of the program
* 3. Can improve development efficiency
* 4. Improve the reliability of the software
* 5. Complexity of control procedures
*
* Declaration of functions
* Function name () {
*
* }
*
* Function name (parameter 1, parameter 2, parameter ...)
* {
* Function Body
* }
*
* Function name ()
* {
* Function body;
* return value;
* }
* Function name (parameter list ...)
* {
* Function body;
* Return value
* }
*
Note
* One, the function must be called to execute, can be called before the declaration, or can be called after the declaration
* Second, function name and variable, AAA BBB CCC AAABBBCCC (the first word lowercase, the first letter of each word capitalized)
* Third, function can not duplicate the name when declaring
* Four, you can change the behavior of the function by passing parameters to the function
* Formal parameters: When declaring a function, the arguments are declared, arguments are variables, multiple parameters are used, separate
* Arguments: Passed to a parameter value (data, or variable) when calling a function
* Five, if no return value is called process
* Vi. returning data by using the return statement
* Seven, the function execution to the return statement is finished, do not write the code after this statement, you can also use return to end the execution of the function
*
* Function Name:
* 1. Call the function and start executing the function
* 2. You can pass data to a function
* 3. Function name is the value returned
*
*
*/
A function of the output table
function table ($tablename, $width, $row, $col)
{
Echo '















';Echo ' ';for ($i =0; $i < $row; $i + +){Interlaced color changeif ($i%2==0)$BG = "#cccccc";Else$BG = "Yellow";Echo ' ';//output line for ($j =0; $j < $col; $j + +) {echo ' '; } Echo '

'. $tablename. '

'. ($i * $row + $j). '
{
Echo '















'; Echo ' '; for ($i =0; $i < $row; $i + +) {//Interlaced color change if ($i%2==0) $BG = "#cccccc"; else $BG = "yellow"; Echo ' ';//output line for ($j =0; $j < $col; $j + +) {echo ' '; } Echo ' '; } Echo '

'. $tablename. '

'. ($i * $row + $j). '
';
}/td> ';
}
Echo '
';
}
Table ("Output table", 600,10,10);
Table ("Output table 2", 300,6,6);
Another way to output
function table2 ($tablename, $width, $row, $col)
{
$str = '















'; $str. = ' '; for ($i =0; $i < $row; $i + +) {//Interlaced color change if ($i%2==0) $BG = "#cccccc"; else $BG = "yellow"; $str. = ' ';//output line for ($j =0; $j < $col; $j + +) {$str. = ' '; } $str. = ' '; } $str. = '

'. $tablename. '

'. ($i * $row + $j). '
';
return $str;
}
echo table2 ("Direct Output form", 400,15,15);
?>

The above describes the Photoshop Learning Web PHP learning Note Function statement, including the Photoshop Learning Web content, I hope the PHP tutorial interested in a friend helpful.

  • 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.