「PHP」通常の引数の参照渡しのサンプル
構文
function 関数名( 引数変数名 ) {
// some code
}
使用例
<?php
function testFunc($x) {
return ++$x;
}
$y= 10;
echo testFunc($y) ."<br>\n";
echo $y ."<br>\n";
?>
<?php
function testFunc($x) {
return ++$x;
}
$y= 10;
echo testFunc($y) ."<br>\n";
echo $y ."<br>\n";
?>
<?php function testFunc($x) { return ++$x; } $y= 10; echo testFunc($y) ."<br>\n"; echo $y ."<br>\n"; ?>
実行結果
11
10