PHPの勉強

Python:

>>> f1 = "hoge"
>>> def f1(x = f1):
	print x

	
>>> def f2(x = f1):
	print x

	
>>> f1()
hoge
>>> f2()
<function f1 at 0x01A07C30>

PHP:

<?php
define("f1", "hoge");

function f1($x=f1){
    echo $x;
}

function f2($x=f1){
    echo $x;
}

f1(); # hoge
f2(); # hoge 
?>

つまりPHPは同じ名前の変数であっても、文脈によっては違うものを指すので名前が衝突しないように気をつける必要がある。まぁ、名前が衝突しないほうが好ましいのはPythonでも同じだけど。