Created
January 20, 2014 04:52
-
-
Save Arakaki/8515014 to your computer and use it in GitHub Desktop.
[PHP]もうPHPの関数にオブジェクトを渡す際に参照渡ししなくてもいいんだよ・・・
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
<?php | |
class Test{} | |
$test1 = new Test(); | |
$test2 = new Test(); | |
//-> 別オブジェクトなのでfalse | |
var_dump($test1 === $test2); | |
//参照渡しではない | |
$test1_2 = getTest($test1); | |
//-> 同一オブジェクトなのでtrue | |
var_dump($test1 === $test1_2); | |
function getTest($test){ | |
return $test; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment