BMH子串查找算法(PHP实现)
代码interface StringSearchable
{
public function search($substring, $buffer);
}
class BoyerMooreStringSearch implements StringSearchable
{
public $substring = null;
public $buffer = '';
public $jumpTable = array();
protected $results = array();
public function __construct()
{
}
public function __destruct()
{
}
public function search($substring, $buffer)
{
$this->results = array();
$this->substring = $substring;
$this->buffer = $buffer;
$this->deriveJumpTable();
$substringLen = strlen($this->substring);
$currentCharIndex = $substringLen - 1;
$bufferLen = strlen($this->buffer);
while ($currentCharIndex < $bufferLen) {
for ($i = $substringLen - 1; $i >= 0; $i--) {
&nb
相关文档:
作用是把形如:www.abc.com/index.php/blog/show 的地址美化成 www.abc.com/blog/show ,使用$_SERVER['PATH_INFO']接收变量。
server
{
listen 80;
server_name myweb;
index index.html index.htm index.php;
root /home/zhaowei/code;
if (!-f $request_filename) {
......
得到客户端的IP(php)
作者: laoyuanyyw 发表日期: 2006-08-01 10:43 文章属性: 原创 复制链接
function get_client_ip()
{
if(getenv('HTTP_CLIENT_IP'))
{
$client_ip = getenv('HTTP_CLIENT_IP');
}
elseif(getenv('HTTP_X_FORWARDED_FOR'))
{
$client_ip = getenv('HTTP_X_FORWARDED_FOR');
}
elseif ......
PHP中的字符串操作功能是比较多的,重要的有以下这些:
(1)echo,print,printf,sprintf
前两个函数是输出字符串.字符串中如果有变量名则被替换成其值. 后两个函数类似于C的同名函数.
(2)strchr,strlen,strtok,strrchr,strrev,strstr,strtolower, strtoupper,substr,ucfirst
这些是常用的字符串操作函数, ......
最近在学PHP ,觉得比较简单,可能是因为有一点编程经验的缘故吧,今天教大家用PHP制作通讯录,功能比较简单,第一次做网页教程,而且不是很有PHP经验,所以不足的地方大家留言告诉我,废话不多说,现在开始
环境:Windows XP SP3 + PHP5 + apache2 + mysql5
首先创建一个数据库,名为 MyDB (我这里使用的是MySQL),SQL ......