Application of 14.final Keywords
This keyword can only be used to define classes and define methods, and you cannot use the final keyword to define member properties because
For final is the meaning of constants, we define constants in PHP using the
First we need to know the concept of a single case pattern, so what is a single case pattern?
Singleton mode, as the name suggests, is only one instance.
As an object's creation pattern, the singleton pattern ensures that a class has only one
Factory mode
Single element mode
Observer mode
Command chain mode
Policy mode
Copy Code code as follows:
class People {
Private $name = ';
Private $user = null;
Private Function __constract ($name) {//* Here Private defines the
If we want to know who is calling a method? Debug_print_backtrace can solve
Debug_print_backtrace () can print a page of the call process, from where to go at a glance.
But this is a proprietary function of the PHP5, but in pear there is already a
The example of this article summarizes the method of exception handling in PHP. Share to everyone for your reference. The specific analysis is as follows:
When an exception is triggered, it usually occurs: An error exception handling module that is
Before PHP5, if you need to use a class, just use Include/require to include it in
test.class.php
Copy Code code as follows:
Class abc{
function __construct ()
{
Echo ' www.hzhuti.com;
}
}
?>
load.php
The
In the Reading YII2 source code when the contact with the trait, I learned a bit, write down the blog record.
Since PHP 5.4.0, PHP implements a code reuse method, called traits.
Traits is a code reuse mechanism prepared for a single inheritance
This is also one of the basic ideas of OO design. Before PHP5, if you need to use a class, just use Include/require to include it in it. The following is a practical example:
Copy Code code as follows:
Class classa{
Public Function
Load variables in text, how do variables output?
1. For Python, use the Format function
Cases:
Date= "Sunday";
Print ("Today is {0}". Format (data)); Output today is Sunday
where {0}{1}{2} ..... Can have multiple, in different locations,
Free to find a little bit of PHP about OO Point of information to see, access control modifiers, self,parent,const,static several keywords, the arrow operator (also called in the book). That is, "->"), the range parsing operator (that is, double
static functionObject_to_array ($obj) {$class _name = ""; Get class Nameif(Is_object ($obj))
{$class _name = Get_class ($obj);
This key has a class name $obj = (array) $obj; $obj 2 =Array(); Key to remove the class nameforeach($obj
Post_class ()Post_class is a built-in function for displaying the class name of an article, which usually generates a unique CLSS value for each article, and if you need to make your own theme and need a little personality, you'd better stop, With
01. Output is mozilla/4.0 (compatible; MSIE5.01; WindowNT5.0), the possible output statements are:
A $_server[' Http_user_agent_type '];
b.$_server[' Http_user_agent '];
c.$_server[' User_agent '];
d.$_server[' AGENT '];
02. The following features
Include and require are two basic ways to introduce files in PHP. There's nothing wrong with using include and require directly in small scale development, but it can cause a lot of include and require accumulation in large projects. Such code is
/**
* Imitation officexp style of the left page list
* --------------------------------------------------------------------------------
* Blood to 2/19/2002 4:47:11 PM affixed to Visual Basic
*
* Xu Zuning (nagging) transplanted in 3/2/2002
* OOP
A flexible string.
Because of the flexibility of the expression, we can use the "mapping" method to bring up a string or function.
$a = ' B ';
$b = ' 123 ';
echo $ $a; This can output 123. But the better habit is the echo ${$a}, which is clearer.
$c
PhpMySQL Read Data
Reading data from MySQL databaseThe SELECT statement is used to read data from the data table:SELECT column_name (s) from table_nameTo learn more about SQL, please visit our SQL Tutorial.In the following example we read the
Three pages are created: (1) register new student information module (register. php ):! DOCTYPEHTMLPUBLIC-W3CDTDHTML4.01TransitionalENwww.w3.orgTRhtml4loose.dtdhtmlheadmetahttp-equivContent-Typecontenttexthtml; charsetgb2312title
Three pages are
Ec (2); php automatically loads function _ autoload () PHP before the magic function _ autoload () method appears, if you want to instantiate 100 objects in a program file, you must use include or require to include 100 class files, or you can
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.