PHP5 object-oriented explanation-(10) _ set () _ get () _ isset () _ unset () four methods. This article briefly introduces four methods for PHP5 object-oriented explanation-(10) _ set () _ get () _ isset () _ unset, if you have any questions,
This article briefly introduces four methods for PHP5 object-oriented explanation-(10) _ set () _ get () _ isset () _ unset, if you have any questions, please refer to them.
Application of four methods: _ set () _ get () _ isset () _ unset ()In
First look at the unset function syntax
unset
Deletes a variable.
Syntax: int unset (mixed Var);
return value: Integer
Function type: PHP system function
Content Description
This function deletes the variable and returns a true value for
PHP unset Global variables can only destroy local variables in actual use, and can not achieve the purpose of global variables. Here we will deal with this problem concretely. Hope to help you.
Some functions in the language of PHP are literally
The unset () function of PHP is used to clear and destroy variables. unused variables can be destroyed using unset. However, in some cases, the memory occupied by destroying variables cannot be reached with unset!
The code is as follows:
For ($ I =
The unset () function of PHP is used to clear and destroy variables. unused variables can be destroyed using unset. However, in some cases, the memory occupied by destroying variables cannot be reached with unset!
Copy codeThe code is as
The PHP unset () function is used to clear, destroy variables, and we can destroy them with unset (). But at some point, using unset () does not achieve the memory that is consumed by destroying variables! Let's look at an example first:
PHP magic methods _ ISSET and _ UNSET use instances __isset _ unset
_ Isset ()-if there is no or non-public attribute when the isset () method is used for attributes in the class or non-class, the _ isset () method is automatically executed.
_ Unset
The PHP unset () function is used to clear, destroy variables, and we can destroy them with unset (). But at some point, using unset () does not achieve the memory that is consumed by destroying variables! Let's look at an example first:PHP
The unset () function of PHP is used to clear and destroy variables. unused variables can be destroyed using unset. However, in some cases, the memory occupied by destroying variables cannot be reached with unset! Let's first look at an example:
In actual use, PHP unset global variables can only destroy local variables and cannot implement global variables. Next we will solve this problem in detail. Hope to help you.
Some functions in PHP are literally hard to understand for beginners. You
In php object-oriented language, _ set _ get _ isset _ unset usage is introduced. We often see the usage of bit _ set _ get _ isset _ unset in php object orientation, but we do not understand why we should use these items, next we will introduce one
Copy CodeThe code is as follows:
for ($i = 1; $i $str = str_repeat (' 01234567 ', $i);
$a = Memory_get_usage ();
Unset ($STR);
$b = Memory_get_usage ();
echo "\ n
". $i. ': '. ($b-$a). ' Bytes. ';
}
As seen from the results:
8 x 32 = 256 It is
Reprinted from: http://www.okajax.com/a/201106/php_unset.html
The unset () function of PHP is used to clear and destroy variables. unused variables can be destroyed using unset. However, in some cases, the memory occupied by destroying variables
The unset function is a function of PHP's own destruction variables, we introduced the use of unset to destroy the static variables and global variables, and can destroy the array variable Oh, let's look at the example below.
Example 1. Unset ()
10. _ set () _ get () _ isset () _ unset () application of four methods In general, the class attribute is always defined as private, which is more in line with the actual logic. However, read the attributeAnd value assignment operations are very
PHP Tutorial Variable Destruction unset usage
Unset--releasing the given variableDescribevoid unset (mixed var [, mixed Var [, ...]])
Unset () destroys the specified variable. Note in PHP 3, unset () returns True (actually an integer value of 1),
Copy codeThe Code is as follows:For ($ I = 1; I I $ Str = str_repeat ('20140901', $ I );$ A = memory_get_usage ();Unset ($ str );$ B = memory_get_usage ();Echo "\ n". $ I. ':'. ($ B-$ a). 'bytes .';} The result shows that:8x32 = 256 it is really
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.