This article provides a detailed analysis of the autoload and spl_autoload automatic loading mechanisms in PHP. For more information, see
PHP autoload mechanism details(1) autoload Mechanism OverviewWhen using the php oo mode to develop a system, we usually get used to storing the implementation of each class in a separate file, which makes it easy to reuse classes, at the same time, it will be very convenient for future maintenance. This is also one of the basic ideas of OO design. Before using
.
Example #1 Example of logical operators
Copy codeThe Code is as follows:
// The following foo () will not be called because they are short-circuited by the operator.
$ A = (false foo ());
$ B = (true | foo ());
$ C = (false and foo ());
$ D = (true or foo ());
// "|" Has a higher priority than "or"
$ E = false | true; // $ e is assigned (false | true) and returns true.
$ F = false or true; // $ f is assigned to false. [Altair note: "=" has a
When using the php oo mode to develop a system, we usually get used to storing the implementation of each class in a separate file, which makes it easy to reuse classes, at the same time, it will be very convenient for future maintenance.
I. Overview of the autoload mechanism
When using the php oo mode to develop a system, we usually get used to storing the implementation of each class in a separate file, which makes it easy to reuse classes, at the same time, it will be very convenient for fu
$ B
And (logical And)
TRUEIf both $ a and $ B areTRUE.
$ A | $ B
Or (logical Or)
TRUEIf either $ a or $ B isTRUE.
Example #1 Example of logical operators
The code is as follows:
// The following foo () will not be called because they are short-circuited by the operator.$ A = (false foo ());$ B = (true | foo ());$ C = (false and foo ());$ D = (true or foo ());// "|" Has a higher priority than "or"$ E = false | true; // $ e is assigned (false | true) and returns
bit of open source software development a long time ago, was fortunate to see an old programmer's resume, let me be shocked that he unexpectedly in Altair This earliest computer creates Macintosh program.Yes, Altair is that even the display and keyboard are not, by the toggle switch to enter, by the light to output the so-called "personal computer", Bill Gates and Paul Allen on the above wrote a Baisc inte
in the brain curing, later programming can be handy.3Solid Foundation, MasteryI took part in a bit of open source software development a long time ago, was fortunate to see an old programmer's resume, let me be shocked that he unexpectedly in Altair This earliest computer creates Macintosh program.Yes, Altair is that even the display and keyboard are not, by the toggle switch to enter, by the light to outp
When developing a system using the PHP OO model, it is often customary to store the implementation of each class in a separate file, which makes it easy to reuse the classes and facilitate future maintenance. This is also one of the basic ideas of OO design. Before PHP5, if you need to use a class, just use the
Include/requireYou can include it in.
The following is a practical example:
Copy CodeThe code is as follows:
/* Person.class.php */
Class Person {
var $name, $age;
function __construct
as follows
Copy Code
The following foo () is not called because they are "shorted" by the operator.$a = (false foo ());$b = (true | | foo ());$c = (False and foo ());$d = (true or foo ());"| |" has a higher priority than "or"$e = False | | True $e is assigned a value of (false | | true), and the result is true$f = False or true; $f is assigned false [Altair NOTE: ' = ' has a higher precedence than ' or ']Var_dump ($e, $f);"" h
Php logic and operator instructions
// The following foo () will not be called because they are short-circuited by the operator.
$ A = (false foo ());
$ B = (true | foo ());
$ C = (false and foo ());
$ D = (true or foo ());
// "|" Has a higher priority than "or"
$ E = false | true; // $ e is assigned (false | true) and returns true.
$ F = false or true; // $ f is assigned to false. [Altair note: "=" has a higher priority than "or"]
Var_du
/* Person.class.php */
Class Person {
Public $name;
Public $age;
function __construct ($name, $age)
{
$this->name = $name;
$this->age = $age;
}
}
?>
/* no_autoload.php */
Require_once ("Person.class.php");
$person = new Person ("Altair", 6);
Var_dump ($person);
?>
Copy CodeIn this example, the no
The following foo () is not called because they are "shorted" by the operator.
$a = (false foo ());
$b = (true | | foo ());
$c = (False and foo ());
$d = (true or foo ());
"| |" has a higher priority than "or"
$e = False | | True $e is assigned a value of (false | | true), and the result is true
$f = False or true; $f is assigned false [Altair NOTE: ' = ' has a higher precedence than ' or ']
Var_dump ($e, $f);
"" has a higher priority than "
This article provides a detailed analysis of the autoload mechanism in PHP. For more information about how to use the php oo mode to develop a system, generally, you are used to storing the implementation of each class in a single file. This makes it easy to reuse classes and facilitates future maintenance. This is also one of the basic ideas of OO design. To use a class before PHP5, you only need to use
Include/requireInclude it.
The following is an example:
The code is as follows:
/* Person.
(1) autoload mechanism OverviewWhen using the PHP oo mode to develop a system, we usually get used to storing the implementation of each class in a separate file, which makes it easy to reuse classes, at the same time, it will be very convenient for future maintenance. This is also one of the basic ideas of OO design. Before using PhP5, to use a class, you only need to directly include it using include/require. The following is an actual example:
/* Person. Class. php */Class person {VaR $ name,
I. Overview of the autoload Mechanism
When using the php oo mode to develop a system, we usually get used to storing the implementation of each class in a separate file, which makes it easy to reuse classes, at the same time, it will be very convenient for future maintenance. This is also one of the basic ideas of OO design. Before using PHP5, to use a class, you only need to directly include it using include/require.The following is an actual example:
Copy codeThe Code is as follows:/* Person
When using the PHP oo mode to develop a system, we usually get used to storing the implementation of each class in a separate file, which makes it easy to reuse classes, at the same time, it will be very convenient for future maintenance. This is also one of the basic ideas of OO design. Before using PhP5, to use a class, you only need to directly include it using include/require. The following is an actual example:
/* Person. Class. php */
Class person {VaR $ name, $ age;
Function _ construct
When using the PHP oo mode to develop a system, we usually get used to storing the implementation of each class in a separate file, which makes it easy to reuse classes, at the same time, it will be very convenient for future maintenance. This is also one of the basic ideas of OO design. To use a class before PhP5, you only need to useInclude/requireInclude it.The following is an example:
CopyCode The Code is as follows:/* person. Class. php */
Class person {
VaR $ name, $ age;
Function _
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.