Created
August 6, 2016 15:26
-
-
Save Restoration/4213e79c8ff69fb9e4319f24a1aaf7e2 to your computer and use it in GitHub Desktop.
参照渡し
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Test</title> | |
| </head> | |
| <body> | |
| <?php | |
| //=&について | |
| //参照、または参照渡し、2つの変数が同じものをさす | |
| $a = '変更前'; | |
| //値渡し、$bには値をコピーしたものが代入される | |
| $b = $a; | |
| //参照渡し $cと$aは同じ値をさす | |
| $c =& $a; | |
| echo '$a' .$a. '<br /> '; | |
| echo '$b' .$b. '<br /> '; | |
| echo '$c' .$c. '<br />'; | |
| $a = '変更後'; | |
| echo '$a' .$a. '<br /> ';//変更後がはいる | |
| echo '$b' .$b. '<br /> ';//$aがコピーされている、$aの値が変わっていても変更されない | |
| echo '$c' .$c. '<br /> ';//$cが変更されて渡される | |
| ?> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment