Home  >  Article  >  Backend Development  >  Static variable changes before call?

Static variable changes before call?

WBOY
WBOYOriginal
2016-12-01 01:27:49956browse

<code>class Test {
    static $name='app';
    static $age=30;
}</code>
<code>$name=Test::$name;
echo $name;</code>

How to change the value of $name before returning in Test?

Reply content:

<code>class Test {
    static $name='app';
    static $age=30;
}</code>
<code>$name=Test::$name;
echo $name;</code>

How to change the value of $name before returning in Test?

If a static variable is changed by you, why would it be called a static variable?

Why do you need to change the value of a static variable before using it? The original intention of static variable setting is to serve as an initial value for calling. You can reassign the static variable and assign it dynamically before using this value

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn