<?php
//Генерируем фамилию
$famtxt = file('comments.txt');
$famstr = $famtxt[ array_rand($famtxt) ];
unset($famtxt);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<title>Генератор</title>
<meta name="keywords" content="генератор" />
<meta name="description" content="Генератор" />
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>
<body>
<div class="wrapper">
<main class="content">
<div class="ribbon"><div class="ribbon-stitches-top"></div><strong class="ribbon-content"><h1>Генератор</h1></strong><div class="ribbon-stitches-bottom"></div></div>
<div class="gendata">
<div class="form-group">
<?php echo $famstr; ?>
</div>
<button onClick='parent.location="javascript:location.reload()"' class="btn btn-success">Хочу другую фразу</button>
</div>
</main>
</div>
<?php
if(isset($_POST['fam']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$famtxt = file('comments.txt');
return $famtxt[array_rand($famtxt)];
}