PHP Course Note 3

Source: Internet
Author: User

  The application of PHP loop structure for statement in  class

1. The number of self-increasing conditions can be determined by themselves, can write multiple

2. The initial value can also be set to multiple

Special Process Control Statements in class

1.break is the exit loop body, followed by a number can indicate the number of exit layers

2.continue is to exit this cycle and continue the next cycle

3.exit (); is the exit script.

Class hours php flow control statement Goto

A 1.goto statement requires a tag.

Tag: (tag can be any name, followed by a colon)

The definition and application of PHP function in class

1. Complexity of Control program design

2. Improve the reliability of the software

3. Improve the efficiency of software development

4. Improve the maintainability of the software

5. Improve the reusability of the program

The syntax format of PHP custom function in class

<?php

function table () {
Echo ' <table border= ' 1 "width=" align= "center" > ";

echo "<eaption>

for ($i =0; $i <10; $i + +) {

$BG = ($i%2 = = 0)? "#cccccc": "";

Echo ' <tr bgcolor= '. $bg. ' > ';

for ($j =0; $j <10; $j + +) {

Echo ' <td> '. ($i *10+ $j). ' </td> ';

}

Echo ' </tr> ';

}

echo "</table>";
}

Table ();

?>

Classes in PHP custom function parameters

<?php

function table ($rows =10, $cols =10) {

Echo ' <table border= ' 1 "width=" align= "center" > ";

echo "<eaption>

for ($i =0; $i < $rows; $i + +) {

$BG = ($i%2 = = 0)? "#cccccc": "";

Echo ' <tr bgcolor= '. $bg. ' > ';

for ($j =0; $j < $cols; $j + +) {

Echo ' <td> '. ($i *10+ $j). ' </td> ';

}

Echo ' </tr> ';

}

echo "</table>";
}

Table ();

?

1. Formal parameter arguments to correspond

?

  The return value in PHP custom functions (return)  

1.file_put_contents ("doc.html", "" ");

2. Function names must be meaningful

3.function_exists (); Determine if a function exists

Class PHP local Variables

1.return can only return one variable

2. Variables inside the function can only be used inside the function.

3. Variables declared in parameters cannot be used externally. The parameter of the function is a local variable.

Class PHP global Variables

1. Global variables, variables declared outside the function are called global variables.

2. All newly declared variables inside the function are new variables.

The 3.global declaration is related to the order. If the variable is in the same name as the external variable within the new declared variable inside the function, only the external variable is displayed.

4. The function can be used only if the global variable is declared before the call, or the value cannot be found.

Lesson bayi php static variable

1.static Static variables

2. Release only at the end of the final script

3. Static variables declared in the function are declared only on the first call,

4. The second time after the look is a static variable, the static segment to see if there is a variable, if there is a direct use, and no longer declared.

5. Static variables, shared when the same function is called multiple times

function of PHP regular parameters in class

PHP Course Note 3

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.