0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PHPで「条件式が偽の時の処理(if..else)」の動作を確認してみた。

Posted at

概要

PHPで「条件式が偽の時の処理(if..else)」の動作を確認してみました。
以下のページを参考にしました。

実装

sample.php
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>PHPテスト</title>
</head>
<body>

<p>PHPのテストです。</p>

<p>
<?php
$old = 18;

print '年齢:'.$old.'<br />';
if ($old >= 20){
  print '年齢は20才以上です<br />';
}else{
  print '年齢は20才未満です<br />';
}

$old = 45;

print '年齢:'.$old.'<br />';
if ($old >= 20){
  print '年齢は20才以上です';
}else{
  print '年齢は20才未満です';
}
?>
</p>

</body>
</html>

以下のコマンドを実行しました。

$ php sample.php 
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>PHPテスト</title>
</head>
<body>

<p>PHPのテストです。</p>

<p>
年齢:18<br />年齢は20才未満です<br />年齢:45<br />年齢は20才以上です</p>

</body>
</html>

まとめ

何かの役に立てばと。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?