「PHP」通常の引数の参照渡しのサンプル

構文
function 関数名( 引数変数名 ) {
// some code
}

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<?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

PHP

Posted by arkgame