LoginSignup
1
1

More than 3 years have passed since last update.

【PHP超初心者】おみくじプログラムを作ってみた

Posted at

はじめに

PHPの超初心者向け書籍を購入し、初めて作ったプログラムを公開します。
rand関数を使って、おみくじプログラムを作ってみました。

おみくじプログラムの中身

Omikuji.php

<?php
$fortunes = array('大吉','中吉','小吉','末吉','凶');
$result = $fortunes[rand(0, count($fortunes)-1)];
echo "あなたの今日の運命は". $result . "です。". PHP_EOL;

発行するとランダムで、今日の運勢が出力されます。
試しに発行してみると、

$ php Omikuji.php 
あなたの今日の運命は凶です。

凶でした。

以下使用している関数など

・array
配列

・rond
乱数を生成する

・PHP_EOL
改行コードを出力する

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