修改 file=file ($path.“这里放文本路径”)
演示站:https://api.xfyun.club/yiyan.php
话不多说直接放代码:
<?php
$path = dirname(FILE);
$file = file($path . “/yiyan/yiyan.txt”);
$arr = mt_rand(0, count($file) - 1);
$content = trim($file[$arr]);
if (isset($GET[‘charset’]) && !empty($GET[‘charset’])) {
$charset = $_GET[‘charset’];
if (strcasecmp($charset, “gbk”) == 0) {
$content = mb_convert_encoding($content, ‘gbk’, ‘utf-8’);
}
} else {
$charset = ‘utf-8’;
}
header(“Content-Type: text/html; charset=$charset”);
if ($_GET[‘format’] === ‘js’) {
echo “function misaka(){document.write(‘” . $content . “’);}”;
} else {
echo $content;
}