no message

This commit is contained in:
a-kizaki
2026-10-09 12:33:29 +09:00
commit c4365a352f
71 changed files with 12139 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<?php
// 20を5で割った値を出力してください
echo 20 / 5;
echo nl2br("\n");
// 126を13で掛けた値を出力してください
echo 126 * 13;
echo nl2br("\n");
// 97を6で割った時の余りを出力してください
echo 97 / 6;

View File

@@ -0,0 +1,10 @@
<?php
$num = 10;
print $num;
// 変数numの値に30を足してください
$num += 30;
// 以下のプログラムで40が出力されるようにしてください
print $num; // ※※ この行は修正しないでください

View File

@@ -0,0 +1,11 @@
<?php
$num1 = 50;
print $num1;
// TODO: 変数num2に140が入るようにしてください
// 括弧と四則演算を使って計算してください....どうすれば140という数値になるか考えてみましょう
$num2 = (20 + $num1) * 2;
// 以下のプログラムで140が表示されるようにしてください
print $num2; // ※※ この行は修正しないでください

View File

@@ -0,0 +1,11 @@
<?php
$d_num = 25;
print $d_num;
// TODO: プログラムを修正して、変数d_numに50が入るようにしてください
// リテラルを使わずに、変数を使って計算してください
$d_num = $d_num + $d_num;
// 以下のプログラムで50が表示されるようにしてください
print $d_num; // ※※ この行は修正しないでください

View File

@@ -0,0 +1,10 @@
<?php
// 変数ageを定義して、数値58を代入してください
$age = 58;
// 変数nameを定義して、文字列"山田"を代入してください
$name = '山田';
// 変数age、nameを連結して、「山田さんは、58歳です」と表示してください
echo $name . 'さんは、' . $age . '歳です';

View File

@@ -0,0 +1,20 @@
<?php
$x = 10;
$y = 50;
print 'x:' . $x;
print '<br>';
print 'y:' . $y;
print '<br>';
// 変数 x, y の値をリテラルな数字を使わずに入れ替えてください
// ※プログラムは何行書いても良いです
$z = $x;
$x = $y;
$y = $z;
// ここから下は修正しないでください
print 'x:' . $x; // 「x:50」が表示される
print '<br>';
print 'y:' . $y; // 「y:10」が表示される

View File

@@ -0,0 +1,10 @@
<?php
$num = 97;
print 'num:' . $num;
print '<br>';
// 変数targetを宣言して、97未満の数字を代入してください
$target = 94;
// 変数numを、変数targetで割った時の商と余りを表示してください
print $num % $target;

View File

@@ -0,0 +1,8 @@
<?php
$num = 20;
$calc = 5;
$name = "鈴木";
// 変数num, calc, nameを連結して、「鈴木さんは、25歳になりました」と表示してください
echo $name . 'さんは、' . $num + $calc . '歳になりました';

View File

@@ -0,0 +1,15 @@
<?php
$length = 9; // 底辺
$height = 23; // 高さ
// 変数quadrangle に、四角形の面積を代入してください
$quadrangle = $length * $height;
// 変数quadrangle を表示してください
echo $quadrangle;
echo '<br>';
// 変数triangle に、三角形の面積を代入してください
$triangle = $length * $height / 2;
// 変数triangle を表示してください
echo $triangle;

View File

@@ -0,0 +1,19 @@
<?php
$moneyInHand = 1000; // 所持金
$coffee = 120; // コーヒーの値段
$snack = 200; // スナック菓子の値段
/*
* ● 1本あたり120円(税別)の缶コーヒーを2本
* ● 1袋あたり200円(税別)のスナック菓子を1袋
*
* 上記商品を購入した時の所持金を表示してください
* ※ 消費税は、全商品の合計に8%が加算されます
* ※ 日本円には小数点がありませんので、整数の値で出力してください
*/
$total = ($coffee * 2) + $snack;
$tax = $total * 0.08;
$taxTruncation = floor($tax);
$moneyInHand = $moneyInHand - ($total + $taxTruncation);
echo '所持金' . $moneyInHand;

View File

@@ -0,0 +1,151 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>PTra02スタートページ</title>
<!-- Bootstrap Core CSS -->
<link href="../common/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="page-header">
<h1>
独習PHP第3章練習問題 <small>式と演算</small>
</h1>
</div>
<div class="panel-group" id="accordion">
<!-- ================== PTra02-01 ================== -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="Ex01.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span>
Ex01
</a> <small>四則演算</small>
</h4>
</div>
</div>
<!-- ================== PTra02-02 ================== -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="Ex02.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span>
Ex02
</a> <small>変数と計算</small>
</h4>
</div>
</div>
<!-- ================== PTra02-03 ================== -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="Ex03.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span>
Ex03
</a> <small>演算子の優先順位</small>
</h4>
</div>
</div>
<!-- ================== PTra02-04 ================== -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="Ex04.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span>
Ex04
</a> <small>計算結果</small>
</h4>
</div>
</div>
<!-- ================== PTra02-05 ================== -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="Ex05.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span>
Ex05
</a> <small>加算と連結</small>
</h4>
</div>
</div>
<!-- ================== PTra02-06 ================== -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="Ex06.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span>
Ex06
</a> <small>スワップ</small>
</h4>
</div>
</div>
<!-- ================== PTra02-07 ================== -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="Ex07.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span>
Ex07
</a> <small>剰余演算</small>
</h4>
</div>
</div>
<!-- ================== PTra02-08 ================== -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="Ex08.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span>
Ex08
</a> <small>連結</small>
</h4>
</div>
</div>
<!-- ================== PTra02-09 ================== -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="Ex09.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span>
Ex09
</a> <small>面積算出</small>
</h4>
</div>
</div>
<!-- ================== PTra02-10 ================== -->
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="Ex10.php" target="_blank"> <span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span>
Ex10
</a> <small>買い物</small>
</h4>
</div>
</div>
</div>
</div>
<!-- jQuery -->
<script src="../common/js/jquery-3.2.1.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="../common/js/bootstrap.min"></script>
</body>
</html>