Skip to content

Instantly share code, notes, and snippets.

@Arakaki
Created January 20, 2014 04:52
Show Gist options
  • Save Arakaki/8515014 to your computer and use it in GitHub Desktop.
Save Arakaki/8515014 to your computer and use it in GitHub Desktop.
[PHP]もうPHPの関数にオブジェクトを渡す際に参照渡ししなくてもいいんだよ・・・
<?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