カテゴリー
PHP

変数のインクルード

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="GENERATOR" content="JustSystems Homepage Builder Version 18.0.14.0 for Windows">
<title></title>
</head>
<body>
 <?php
  require_once ("newpage8.php");
  print $APPTITLE;

function SampFuncNo1() {
  print "値渡し<BR>";
  print "ポイント2 → $vol<BR>";
  $vol = $vol * 2;
  print "ポイント3 → $vol<BR>";
  return $vol;
}
function SampFuncNo2(&$a) {
  print "参照渡し<BR>";
  print "ポイント2 → $a<BR>";
  $a = $a * 2;
  print "ポイント3 → $a<BR>";
  return $a;
}

  MyTitlePrint("実験開始!関数(値渡しと参照渡し)");
  $vol = 100;
  print "<HR>";
  print "ポイント1 → $vol<BR>";
  $ret = SampFuncNo1($vol);
  print "ポイント4 → $vol<BR>";

  $vol = 100;
  print "<HR>";
  print "ポイント1 → $vol<BR>";
  $ret = SampFuncNo2($vol);
  print "ポイント4 → $vol<BR>";

?>

<p><a href="index.php">トップページへ戻る</a></p>

</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="GENERATOR" content="JustSystems Homepage Builder Version 18.0.14.0 for Windows">
<title></title>
</head>
<body>
  <?php
  function MyTitlePrint($str){
    print "<H2>$str</H2>";
    return;
  }
  function fontcolor($moji, $color) {
    $a = "<B><FONT color='$color'>" . $moji . "</FONT></B>";
    return $a;
  }

  $a = "<H2>山爺の";
  $a .= fontcolor("PHP", "#6666FF");
  $a .= fontcolor("試行錯誤的実験室", "FF0000") . "</H2><BR>";
  $APPTITLE = $a;

  ?>
</body>
</html>

前にアップした時と違ってきているので、newpage8.php関数の値渡しと参照渡し例を再度表示します。

inserted by FC2 system