LoginSignup
2
1

More than 1 year has passed since last update.

PHPの定数のサンプルプログラム

Posted at

PHPで定数のサンプルプログラムを実装しました。
全体のプログラムです

<!-- 定数のWORKプログラム作成 -->
<!-- 新規作成 2022/12/27 -->
<!-- Program name work35a.php -->
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>WORK35A</title>
  <style>
    .test1 {
      color:#F00;
      font-weight:bold;
    }
  </style>  
</head>
<body>
  <?php
      define('TEAM_NAME','really?Madrid');
      define('ADD',10);

      function echo_team($person){
        echo "<p>チーム名は<span class=test1>" . TEAM_NAME . "</span>です</p>";
        echo "<p>現在所属人数は" . $person . "人で、来月" . ($person + ADD) . "人になります。</p>";
      }

      echo_team(30);

  ?>
</body>
</html>
<?php
      // チーム名を定義する。
      define('TEAM_NAME','really?Madrid');
      // 加わる人数を定義する
      define('ADD',10);

      // チームに関する関数 
      function echo_team($person){
        echo "<p>チーム名は<span class=test1>" . TEAM_NAME . "</span>です</p>";
        echo "<p>現在所属人数は" . $person . "人で、来月" . ($person + ADD) . "人になります。</p>";
      }
      // 関数の呼び出し
      echo_team(30);

  ?>
define(変数名,変数の値);

で定義します。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1