This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $text = file_get_contents('/path/to/mypage_login.log'); | |
| $target = file_get_contents('/path/to/member_num.txt'); | |
| $member_num = explode("\n", $target); | |
| $match_num = []; | |
| foreach ($member_num as $num) { | |
| $search = strpos($text, $num); | |
| if ($search !== false) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $coin_type = [1 => 10, 2 => 50, 3 => 100, 4 => 500]; | |
| $change = $argv[2] - $argv[1]; | |
| echo '代金:' . $argv[1] . "\n"; | |
| echo 'お金:' . $argv[2] . "\n"; | |
| echo '釣り:' . $change . "\n\n"; | |
| for ($i = 3; $i >= 1; $i--){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $days_per_month = [ | |
| [1 => 31, 2 => 28, 3 => 31, 4 => 30, 5 => 31, 6 => 30, 7 => 31, 8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 => 31], | |
| [1 => 31, 2 => 59, 3 => 90, 4 => 120, 5 => 151, 6 => 181, 7 => 212, 8 => 243, 9 => 273, 10 => 304, 11 => 334, 12 => 365] | |
| ]; | |
| $month = rand(1, 12); | |
| $date = rand(1, $days_per_month[0][$month]); | |
| echo $month . '月' . $date . '日までの通算日数:'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $hand = array('グー', 'チョキ', 'パー', 'OK'); | |
| $ok_used = array('未', '済'); | |
| $okFlg_taro = 0; | |
| $okFlg_hanako = 0; | |
| // 10回勝負で太郎と花子が出した手に応じて勝敗を出力 | |
| for($i = 1; $i <= 10; $i++) { | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // じゃんけんに見立てて0~2までのランダムな数字を各変数にセット | |
| $taro = rand(0, 2); | |
| $hanako = rand(0, 2); | |
| // 各数字をキーにしたじゃんけんの手を配列に格納し、各自の出した手として出力 | |
| $hand = array(0 => 'グー', 1 => 'チョキ', 2 => 'パー'); | |
| echo '太郎:' . "[{$taro}] " . $hand[$taro] . '<br>'; | |
| echo '花子:' . "[{$hanako}] " . $hand[$hanako] . '<br>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 出典: | |
| * http://www.objective-php.net/basic/abstract | |
| */ | |
| abstract class TimeMeasurer | |
| { | |
| abstract protected function process(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>IPアドレス&ホスト名検索フォーム | Webアプリケーション スーパーサンプル</title> | |
| </head> | |
| <body> | |
| <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST"> | |
| <table> | |
| <tr> | |
| <td>IPアドレスまたはホスト名:<input type="text" name="host"></td> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| public function slugify($text) | |
| { | |
| // 非文字や数字を'-'に置換する | |
| $text = preg_replace('#[^\\pL\d]+#u', '-', $text); | |
| // 前後の'-'を取り除く | |
| $text = trim($text, '-'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>ファイル名を変更する | Webアプリケーション スーパーサンプル</title> | |
| </head> | |
| <body> | |
| <?php | |
| /** | |
| * 出典: |