⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 friendly.php

📁 AJAX and PHP: Building Responsive Web Applications源代码
💻 PHP
字号:
<?php
// load the error handling module
require_once('error_handler.php');
require_once('friendly.class.php');
// make sure the user's browser doesn't cache the result
header('Expires: Wed, 23 Dec 1980 00:30:00 GMT'); // time in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
// retrieve the action parameter
$action = $_GET['action'];
// check availability or get new random number?
if ($action == 'GetNumber')
{

}
elseif ($action == 'CheckAvailability')
{
  // adress of page that returns buffer level
  $serverAddress = 'http://www.random.org/cgi-bin/checkbuf';
  // received buffer level is in form 'x%'
  $bufferPercent = file_get_contents($serverAddress);
  // extract the number 
  $buffer = substr($bufferPercent, 0, strlen($bufferPercent) - 2);
  // echo the number
  echo $buffer;
}
else
{
  echo 'Error talking to the server.';
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -