Php practices: 13th days. Today, we re-developed object-oriented programming, I realized _ construct, a magic method for instantiating object parameters, and _ destruct, a magic method executed before an object is destroyed, and _ get to obtain private. today I re-implemented object-oriented programming, the magic method of _ construct a instantiated object parameter is also known as _ destruct the magic method executed before an object is destroyed.
And
_ Get: the first parameter for obtaining private member attributes is the obtained name.
_ Set the first parameter for setting the private member attribute is the member name, and the second parameter is the passed value.
_ Call: if no method is found, the first parameter is the name of the call, and the second parameter is the passed parameter.
_ Isset is used to determine whether a member has the first parameter member name.
_ Unset is called when a member is destroyed.
[Php]
/*
* Function strmin: for example, if you want to get the full text as "12345", you need to retrieve "3", "2" before <3>, and "4" after <3> ",
* The parameter $ nString is of the text type. for example, if you want to obtain the full text, the value is 12345.
* The parameter $ sString is of the text type. the parameter is preceded by "2 ",
* Parameter $ eString text type, followed by "4"
* The parameter $ position is an integer that can be null. it indicates the start position of the text to be searched.
* Parameter $ isStr, logical type, can be empty. the default value is case-insensitive.
*/
Function strmin ($ nString, $ sString, $ eString, $ position = 0, $ isStr)
{
If ($ isStr ){
$ S = strpos ($ nString, $ sString, $ position );
$ E = strpos ($ nString, $ eString, $ s );
} Else {
$ S = stripos ($ nString, $ sString, $ position );
$ E = strpos ($ nString, $ eString, $ s );
}
$ S = $ s + strlen ($ sString );
$ E = $ e-$ s;
Return substr ($ nString, $ s, $ e );
}
/*
* The strleft function starts from the left side of the text and searches for the text to be searched.
* Parameter $ nString text type, the searched text
* Parameter $ string text type, the text to be searched
* The parameter $ position is an integer that can be null. it indicates the start position of the text to be searched.
* Parameter $ isStr, logical type, can be empty. the default value is case-insensitive.
* The parameter $ goNum is an integer that can be null. the number of skipping times is 0 by default.
*/
Function strleft ($ nString, $ string, $ position = 0, $ isStr = false, $ goNum = 0)
{
$ P = $ position;
Do {
$ GoNum --;
Echo $ p ."
";
If ($ isStr ){
$ P = strpos ($ nString, $ string, $ p );
} Else {
$ P = stripos ($ nString, $ string, $ p );
}
$ P ++;
} While ($ goNum> = 0 );
$ P --;
Return substr ($ nString, 0, $ p );
}
/*
* Function strmin: for example, if you want to get the full text as "12345", you need to retrieve "3", "2" before <3>, and "4" after <3> ",
* The parameter $ nString is of the text type. for example, if you want to obtain the full text, the value is 12345.
* The parameter $ sString is of the text type. the parameter is preceded by "2 ",
* Parameter $ eString text type, followed by "4"
* The parameter $ position is an integer that can be null. it indicates the start position of the text to be searched.
* Parameter $ isStr, logical type, can be empty. the default value is case-insensitive.
*/
Function strmin ($ nString, $ sString, $ eString, $ position = 0, $ isStr)
{
If ($ isStr ){
$ S = strpos ($ nString, $ sString, $ position );
$ E = strpos ($ nString, $ eString, $ s );
} Else {
$ S = stripos ($ nString, $ sString, $ position );
$ E = strpos ($ nString, $ eString, $ s );
}
$ S = $ s + strlen ($ sString );
$ E = $ e-$ s;
Return substr ($ nString, $ s, $ e );
}
/*
* The strleft function starts from the left side of the text and searches for the text to be searched.
* Parameter $ nString text type, the searched text
* Parameter $ string text type, the text to be searched
* The parameter $ position is an integer that can be null. it indicates the start position of the text to be searched.
* Parameter $ isStr, logical type, can be empty. the default value is case-insensitive.
* The parameter $ goNum is an integer that can be null. the number of skipping times is 0 by default.
*/
Function strleft ($ nString, $ string, $ position = 0, $ isStr = false, $ goNum = 0)
{
$ P = $ position;
Do {
$ GoNum --;
Echo $ p ."
";
If ($ isStr ){
$ P = strpos ($ nString, $ string, $ p );
} Else {
$ P = stripos ($ nString, $ string, $ p );
}
$ P ++;
} While ($ goNum> = 0 );
$ P --;
Return substr ($ nString, 0, $ p );
}
Into _ construct a magic method for instantiating object parameters and _ destruct the magic method executed before an object is destroyed and _ get to obtain private...