Results of 1 - 2 of about 2 for exampleFunction (0.004 sec.)
- 変数のスコープ 11228
- « 定義済みの変数 可変変数 » PHP Manual 変数 変数のスコープ 検索 変数のスコープ 変数のスコープは、その変数が定義されたコンテキストです。 PHP には関数スコープとグローバルスコープがあります。 関数の外部で定義されたあらゆる変数は、グローバルスコ
... れるたびに無名関数が再作成される場合、 static 変数は再初期化されます。 例10 無名関数の内部にある static 変数 <?php function exampleFunction ( $input ) { $result = (static function () use ( $input ) { static $counter = 0 ; $counter ++; return "Input: $input , Cou ... nter: $counter \n" ; }); return $result (); } // Calls to exampleFunction will recreate the anonymous function, so the static // variable does not retain its value. echo exampleFunction ( 'A' ); / ... / Outputs: Input: A, Counter: 1 echo exampleFunction ( 'B' ); // Outputs: Input: B, Counter: 1 (オーバーライドされていない場合) 内部でstatic 変数を使ったメソッドも継承されます ...
-
https://man.mtool.work/php/8.3/language.variables.scope.html
- 変数のスコープ 7485
- « 定義済みの変数 可変変数 » PHP Manual 変数 変数のスコープ 検索 変数のスコープ 変数のスコープは、その変数が定義されたコンテキストです。 PHP には関数スコープとグローバルスコープがあります。 関数の外部で定義されたあらゆる変数は、グローバルスコ
... れるたびに無名関数が再作成される場合、 static 変数は再初期化されます。 例10 無名関数の内部にある static 変数 <?php function exampleFunction ( $input ) { $result = (static function () use ( $input ) { static $counter = 0 ; $counter ++; return "Input: $input , Cou ... nter: $counter \n" ; }); return $result (); } // Calls to exampleFunction will recreate the anonymous function, so the static // variable does not retain its value. echo exampleFunction ( 'A' ); / ... / Outputs: Input: A, Counter: 1 echo exampleFunction ( 'B' ); // Outputs: Input: B, Counter: 1 (オーバーライドされていない場合) 内部でstatic 変数を使ったメソッドも継承されます ...
-
https://man.mtool.work/php/8.3/language.variables.scope.html
PREV
1
NEXT