解决php编译中遇到各种error办法

 更新时间:2016年11月25日 15:33  点击:2396
php编译安装碰到各种的问题了,我们这里整理了一篇关于解决php编译中遇到各种error办法的文章,希望此文章能够为各位带来帮助呀。
1) Configure: error: xml2-config not found. Please check your libxml2 installation.

 

Solutions :

 

Quote:

 

 

 

# yum install libxml2 libxml2-devel

 

 

 

2) Checking for pkg-config… /usr/bin/pkg-config configure: error: Cannot find OpenSSL’s <evp.h>

 

Solutions :

 

Quote:

 

 

 

# yum install openssl openssl-devel

 

 

 

3) Configure: error: Please reinstall the BZip2 distribution

 

Solutions :

 

Quote:

 

 

 

# yum install bzip2 bzip2-devel

 

 

 

4) Configure: error: Please reinstall the libcurl distribution -easy.h should be in <curl-dir>/include/curl/

 

Solutions :

 

Quote:

 

 

 

# yum install curl curl-devel

 

 

 

5) Configure: error: libjpeg.(also) not found.

 

Solutions :

 

Quote:

 

 

 

# yum install libjpeg libjpeg-devel

 

 

 

6) Configure: error: libpng.(also) not found.

 

Solutions :

 

Quote:

 

 

 

# yum install libpng libpng-devel

 

 

 

7) Configure: error: freetype.h not found.

 

Solutions :

 

Quote:

 

 

 

#yum install freetype-devel

 

 

 

8) Configure: error: Unable to locate gmp.h

 

Solutions :

 

Quote:

 

 

 

# yum install gmp-devel

 

 

 

9) Configure: error: Cannot find MySQL header files under /usr. Note that the MySQL client library is not bundled anymore!

 

Solutions :

 

Quote:

 

 

 

# yum install mysql-devel

 

 

 

10) Configure: error: Please reinstall the ncurses distribution

 

Solutions :

 

Quote:

 

 

 

# yum install ncurses ncurses-devel

 

 

 

11) Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!

 

Solutions :

 

Quote:

 

 

 

# yum install unixODBC-devel

 

 

 

12) Configure: error: Cannot find pspell

 

Solutions :

 

Quote:

 

 

 

# yum install pspell-devel

 

 

 

13) configure: error: mcrypt.h not found. Please reinstall libmcrypt.

 

Solutions :

 

Quote:

 

 

 

# yum install libmcrypt libmcrypt-devel

 

 

 

14) Configure: error: snmp.h not found. Check your SNMP installation.

 

Solutions :

 

Quote:

 

 

 

# yum install net-snmp net-snmp-devel

 

 

 

15)configure: error: Please reinstall libmhash – I cannot find mhash.h

 

 

 

#yum install mhash-devel
二分法查找在高级点的开发可能会用到了,当然在大公司找工作时都会有面试题是这种了,下面我们来看一篇关于二分法查找在php中实现方法,具体的细节如下所示。

二分法(dichotomie) 即一分为二的方法. 设[a,b]为R的闭区间. 逐次二分法就是造出如下的区间序列([an,bn]):a0=a,b0=b,且对任一自然数n,[an+1,bn+1]或者等于[an,cn],或者等于[cn,bn],其中cn表示[an,bn]的中点.

例子1


header('Content-Type: text/html; charset=utf-8;');

$arr = array(2,33,22,1,323,321,28,36,90,123);
sort($arr);

//二分法查找
echo $index = binarySearch($arr,321);

function binarySearch($arr,$key){
 $len = count($arr);
 $mid = -1;
 $start = 0;
 $end   = $len-1;

 while($start<=$end){
  $mid = (int)(($start+$end)/2);
  echo $mid."\n";
  if($arr[$mid] == $key){
   return $mid;
  }else if($arr[$mid] < $key){
   $start = $mid+1;
  }else if($arr[$mid] > $key){
   $end = $mid-1; 
  }
 }
}


例子2

<?php
//search函数 其中$array为数组,$k为要找的值,$low为查找范围的最小键值,$high为查找范围的最大键值
function search($array, $k, $low=0, $high=0) 
{
    if(count($array)!=0 and $high == 0)     //判断是否为第一次调用
    {
        $high = count($array);
    }
    if($low <= $high)        //如果还存在剩余的数组元素
    {
        $mid = intval(($low+$high)/2);      //取$low和$high的中间值
        if ($array[$mid] == $k)       //如果找到则返回
        {
            return $mid;
        }
        elseif ($k < $array[$mid])      //如果没有找到,则继续查找
        {
            return search($array, $k, $low, $mid-1);
        }
        else
        {
            return search($array, $k, $mid+1, $high);
        }
    }
    return -1;
}
$array = array(4,5,7,8,9,10);       //测试search函数
echo search($array, 8);        //调用search函数并输出查找结果
?>

PHP使用星号替代用户名手机和邮箱这个在许多的活动界面会看到如淘宝的购物界面中的一些客户的支付宝号都是隐藏掉的哦,下面我们来看一下它的使用方法吧。

<?php

function hideStar($str) { //用户名、邮箱、手机账号中间字符串以*隐藏
    if (strpos($str, '@')) {
        $email_array = explode("@", $str);
        $prevfix = (strlen($email_array[0]) < 4) ? "" : substr($str, 0, 3); //邮箱前缀
        $count = 0;
        $str = preg_replace('/([\d\w+_-]{0,100})@/', '***@', $str, -1, $count);
        $rs = $prevfix . $str;
    } else {
        $pattern = '/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i';
        if (preg_match($pattern, $str)) {
            $rs = preg_replace($pattern, '$1****$2', $str); // substr_replace($name,'****',3,4);
        } else {
            $rs = substr($str, 0, 3) . "***" . substr($str, -1);
        }
    }
    return $rs;
}
?>

<?php
$account = "111cn.net";
$email = "416148489@qq.com";
$phone = "18005152525";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>演示:PHP以星号隐藏用户名手机和邮箱</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
        <link rel="stylesheet" type="text/css" href="http://www.111cn.net  /jquery/css/common.css" />
        <style type="text/css">
        </style>
    </head>
    <body>
        <div class="head">
            <div class="head_inner clearfix">
                <ul id="nav">
                    <li><a href="http://www.111cn.net  ">首 页</a></li>
                    <li><a href="http://www.111cn.net  /templates">网站模板</a></li>
                    <li><a href="http://www.111cn.net  /js">网页特效</a></li>
                    <li><a href="http://www.111cn.net  /php">PHP</a></li>
                    <li><a href="http://www.111cn.net  /site">精选网址</a></li>
                </ul>
                <a class="logo" href="http://www.111cn.net  "><img src="http://www.111cn.net  /Public/images/logo.jpg" alt="素材火logo" /></a>
            </div>
        </div>
        <div class="container">
            <div class="demo">
                <h2 class="title"><a href="http://www.111cn.net  /js/548.html">教程:PHP以星号隐藏用户名手机和邮箱</a></h2>

                <table width="100%" class="table_parameters">
                    <tr class="tr_head">
                        <td>账号</td>
                        <td>邮箱</td>
                        <td>手机</td>
                    </tr>
                    <tr>
                        <td><?php echo $account; ?></td>
                        <td><?php echo $email; ?></td>
                        <td><?php echo $phone; ?></td>
                    </tr>
                    <tr class="red">
                        <td><?php echo hideStar($account); ?></td>
                        <td><?php echo hideStar($email); ?></td>
                        <td><?php echo hideStar($phone); ?></td>
                    </tr>
                </table>
            </div>
        </div>
      
    </body>
</html>

文章分页用到比较多同时使用过cms的朋友也碰到过都具备了文章分页功能了,下面我们自己来看一个关于文章分页的例子,具体的操作步骤如下所示,希望文章能够帮助到各位朋友


content.txt

这个文件里面放的是内容了,如果你是与mysql数据库结合的话只要把把这一句换成你的数据库的内容即可。

index.php文件

      
<link rel="stylesheet" type="text/css" href="http:///jquery/css/common.css" />
        <style type="text/css">
            .demo{width:80%;margin:50px auto 10px auto;padding:10px;}
            .demo p{line-height:30px;text-indent:2em}
            .demo h3{font-size:24px;text-align:center;padding:10px}
            @media (max-width: 480px){
                .demo{width:360px;margin:50px auto 10px auto;padding:10px;}
                .demo img{width:90%}
                .demo h3{font-size:1.5em;line-height:1.9em}
            }
            .pages{text-align:center;border-top:1px solid #d3d3d3;margin-top:10px; padding-top:10px}
            .pages a{display:inline-block;margin:4px;padding:4px 8px;background:#f9f9f9;border:1px solid #d9d9d9}
            .pages a.cur{cursor:default;background:#d3d3d3;color:#434343}
            .pages a.cur:hover{text-decoration:none}
        </style>

        <div class="head">
            <div class="head_inner clearfix">
                <ul id="nav">
                    <li><a href="http://">首 页</a></li>
                    <li><a href="http:///templates">网站模板</a></li>
                    <li><a href="http:///js">网页特效</a></li>
                    <li><a href="http:///php">PHP</a></li>
                    <li><a href="http:///site">精选网址</a></li>
                </ul>
                <a class="logo" href="http://"><img src="http:///Public/images/logo.jpg" alt="素材火logo" /></a>
            </div>
        </div>
        <div class="container">
            <div class="demo">
                <h2 class="title"><a href="http:///js/639.html">教程:PHP长文章分页教程与演示</a></h2>
                <h3>未来10年千万人将没有工作?</h3>
                <?php
                include('page.class.php');
                //自定义的长文章字符串,可以包含 html 代码,若字符串中有手动分页符 {nextpage} 则优先按手动分页符进行分页   
                $content = file_get_contents('content.txt');
                $ipage = isset($_GET["ipage"]) ? intval($_GET["ipage"]) : 1;
                $CP = new cutpage($content);
                $page = $CP->cut_str();
                echo $page[$ipage - 1];
                echo '<div class="pages">' . $CP->pagenav() . '</div>';
                ?>


            </div>
        </div>

长文章分页类  page.class.php

<?php   
/* 
*  长文章分页类    
*/ 
    class cutpage{   
        private $pagestr;       //被切分的内容   
        private $pagearr;       //被切分文字的数组格式   
        private $sum_word;      //总字数(UTF-8格式的中文字符也包括)   
        private $sum_page;      //总页数   
        private $page_word;     //一页多少字   
        private $cut_tag;       //自动分页符   
        private $cut_custom;    //手动分页符   
        private $ipage;         //当前切分的页数,第几页   
        private $url;   
  
        function __construct($pagestr,$page_word=1000){   
            $this->page_word = $page_word;   
            $this->cut_tag = array("</table>", "</div>", "</p>", "<br/>", "”。", "。", ".", "!", "……", "?", ",");   
            $this->cut_custom = "{nextpage}";   
            $tmp_page = isset($_GET["ipage"]) ? intval($_GET["ipage"]) : 1;   
            $this->ipage = $tmp_page>1?$tmp_page:1;
   $this->pagestr = $pagestr;
        }   
        //统计总字数   
        function get_page_word(){   
            $this->sum_word = $this->strlen_utf8($this->pagestr);   
            return $this->sum_word;   
        }   
        /*  统计UTF-8编码的字符长度 
         *  一个中文,一个英文都为一个字 
         */ 
        function strlen_utf8($str){   
           $i = 0;   
           $count = 0;   
           $len = strlen ($str);   
           while ($i < $len){   
               $chr = ord ($str[$i]);   
               $count++;   
               $i++;   
               if ($i >= $len)   
                   break;   
               if ($chr & 0x80){   
                   $chr <<= 1;   
                   while ($chr & 0x80) {   
                       $i++;   
                       $chr <<= 1;   
                   }   
               }   
           }   
           return $count;   
        }   
        //设置自动分页符号   
        function set_cut_tag($tag_arr=array()){   
            $this->cut_tag = $tag_arr;   
        }   
        //设置手动分页符   
        function set_cut_custom($cut_str){   
            $this->cut_custom = $cut_str;   
        }   
        function show_cpage($ipage=0){   
            $this->cut_str();   
            $ipage = $ipage ? $ipage:$this->ipage;   
            return $this->pagearr[$ipage];   
        }   
        function cut_str(){   
            $str_len_word = strlen($this->pagestr);     //获取使用strlen得到的字符总数   
            $i = 0;   
            if ($str_len_word<=$this->page_word){   //如果总字数小于一页显示字数   
                $page_arr[$i] = $this->pagestr;   
            }else{   
                if (strpos($this->pagestr, $this->cut_custom)){   
                    $page_arr = explode($this->cut_custom, $this->pagestr);   
                }else{   
                    $str_first = substr($this->pagestr, 0, $this->page_word);   //0-page_word个文字    cutStr为func.global中的函数   
                    foreach ($this->cut_tag as $v){   
                        $cut_start = strrpos($str_first, $v);       //逆向查找第一个分页符的位置   
                        if ($cut_start){   
                            $page_arr[$i++] = substr($this->pagestr, 0, $cut_start).$v;   
                            $cut_start = $cut_start + strlen($v);   
                            break;   
                        }   
                    }   
                    if (($cut_start+$this->page_word)>=$str_len_word){  //如果超过总字数   
                        $page_arr[$i++] = substr($this->pagestr, $cut_start, $this->page_word);   
                    }else{   
                        while (($cut_start+$this->page_word)<$str_len_word){   
                            foreach ($this->cut_tag as $v){   
                                $str_tmp = substr($this->pagestr, $cut_start, $this->page_word);        //取第cut_start个字后的page_word个字符   
                                $cut_tmp = strrpos($str_tmp, $v);       //找出从第cut_start个字之后,page_word个字之间,逆向查找第一个分页符的位置   
                                if ($cut_tmp){   
                                    $page_arr[$i++] = substr($str_tmp, 0, $cut_tmp).$v;   
                                    $cut_start = $cut_start + $cut_tmp + strlen($v);   
                                    break;   
                                }   
                            }     
                        }   
                        if (($cut_start+$this->page_word)>$str_len_word){   
                            $page_arr[$i++] = substr($this->pagestr, $cut_start, $this->page_word);   
                        }   
                    }   
                }   
            }   
            $this->sum_page = count($page_arr);     //总页数   
            $this->pagearr = $page_arr; 
   return $page_arr;
        }   
        //显示上一条,下一条   
        function pagenav(){   
            $this->set_url();   
            $str = '';
   
   //$str .= $this->ipage.'/'.$this->sum_page;
   
   for($i=1;$i<=$this->sum_page;$i++){
    if($i==$this->ipage) {
     $str.= "<a href='#' class='cur'>".$i."</a> ";
    }else{
     $str.= "<a href='".$this->url.$i."'>".$i."</a> ";
    }
   }
   
             
            return $str;   
        }   
  function show_prv_next2(){   
            $this->set_url();   
            $str = '';
   
   
   
            if ($this->sum_page>1 and $this->ipage>1){   
                $str.= "<a href='".$this->url.($this->ipage-1)."'>上一页</a> ";   
            }  
   if ($this->sum_page>1 and $this->ipage<$this->sum_page){   
                $str .= "<a href='".$this->url.($this->ipage+1)."'>下一页</a>";   
            }      
            return $str;   
        }   
        function show_page_select(){   
            if ($this->sum_page>1){   
                $str = "   <select onchange='location.href=this.options[this.selectedIndex].value'>";   
                for ($i=1; $i<=$this->sum_page; $i++){   
                    $str.= "<option value='".$this->url.$i."' ".(($this->ipage)==$i ? " selected='selected'":"").">第".$i."页</option>";   
                }   
                $str.= "</select>";   
            }   
            return $str;   
        }   
        function show_page_select_wap(){   
            if ($this->sum_page>1){   
                $str = "<select ivalue='".($this->ipage-1)."'>";   
                for ($i=1; $i<=$this->sum_page; $i++){   
                    $str.= "<option onpick='".$this->url.$i."'>第".$i."节</option>";   
                }   
                $str.= "</select>";   
            }   
            return $str;   
        }   
        function set_url(){   
            parse_str($_SERVER["QUERY_STRING"], $arr_url);   
            unset($arr_url["ipage"]);   
            if (empty($arr_url)){   
                $str = "ipage=";   
            }else{   
                $str = http_build_query($arr_url)."&ipage=";   
            }   
            $this->url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]."?".$str;   
        }   
    }   
?>

php实现上一篇下一篇这个主要是通过sql来根据当前的id来进行判断然后筛选出当前ID之前的数据或ID之后的数据了就这么简单,具体的我们来看看。

实现网站文章里面上一篇和下一篇的sql语句的写法。

当前文章的id为 $article_id,当前文章对应分类的id是$cat_id,那么上一篇就应该是:
代码如下

SELECT max(article_id) FROM article WHERE article_id < $article_id AND cat_id=$cat_id;

执行这段sql语句后得到 $max_id,然后

SELECT article_id, title FROM article WHERE article_id = $max_id;

简化一下,转为子查询即:

SELECT article_id, title FROM article WHERE article_id = (SELECT max(article_id) FROM article WHERE article_id < $article_id AND cat_id=$cat_id);

下一篇为:

代码如下

SELECT min(article_id) FROM article WHERE article_id > $article_id AND cat_id=$cat_id;

执行这段sql语句后得到 $min_id,然后

SELECT article_id, title FROM article WHERE article_id = $min_id;

简化一下,转为子查询即:
代码如下

SELECT article_id, title FROM article WHERE article_id = (SELECT min(article_id) FROM article WHERE article_id > $article_id AND cat_id=$cat_id);

最后讲一下有很多朋友喜欢使用下面语句

上一篇:
代码如下

select id from table where id10 limit 0,1;

这样肯定没有问题,但是是性能感觉不怎么地。

sql语句优化

你可以使用union all来实现一条语句取3行数据,但是前提是3个查询的字段要相同

这个查询出来的结果第一行就是上一篇文章,第二行是当前文章,第三行是下一篇文章
代码如下

(select id from table where id < 10 order by id asc limit 1) union all (select id from table where id = 10) union all (select id from table where id > 10 order by id desc limit 1);

现在来看一些cms中的例子phpcms 实现上一篇下一篇

获取当前浏览文章id

$id = isset($_GET['id']) > 0 ? intval($_GET['id']) : "";
下一篇文章

$query = mysql_query("SELECT id,title FROM article WHERE id>'$id' ORDER BY id ASC LIMIT 1");
$next = mysql_fetch_array($query);

上一篇文章

$query = mysql_query("SELECT id,title FROM article WHERE id <'$id' ORDER BY id DESC LIMIT 1");
$prev = mysql_fetch_array($query);


   


        "><?php echo="">        
   


   


        "><?php echo=""> 
   


[!--infotagslink--]

相关文章

  • 409错误是什么 http 409错误怎么解决

    409错误是什么?http 409错误怎么解决呢?不少站长在遇到这个错误代码之后都一筹莫展,本次一聚教程网为大家带来了详细的说明,快来看看吧。 409错误是什么: HTTP 40...2017-01-22
  • http 405错误是什么 http 405错误怎么解决

    http 405错误是什么?http 405错误怎么解决?相信很多站长都在找这两个问题的答案,本次小编为大家带来了详细的教程,快来看看吧。 405错误是什么: HTTP 405错误是H...2017-01-22
  • 403错误是什么 403错误怎么解决

    403错误是HTTP状态码的一种,属于“请示错误”,表示服务器拒绝请求。如果在搜索引擎尝试抓取您网站上的有效网页时显示此状态代码,那么,这可能是您的服务器或主机拒绝搜索...2017-01-22
  • Go应用中优雅处理Error的技巧总结

    在程序员中,尤其是go新手,经常听到的一个讨论话题是:如何处理错误,这篇文章主要给大家介绍了关于Go应用中优雅处理Error的一些相关技巧,需要的朋友可以参考下...2021-09-08
  • 412错误是什么 412错误怎么解决

    412错误是什么?412错误怎么解决?本次一聚教程网将为大家带来详细的介绍,帮助大家全面了解412错误的意思以及解决412错误的方法。 412错误是什么: HTTP 412错误,(Precond...2017-01-22
  • Perl CPAN::Modulelist的解决办法

    今天用CPAN安装Term::ReadLine,报了个这样的错误 Going to read /root/.cpan/sources/modules/03modlist.data.gz Can't locate object method "data" via package "C...2016-11-25
  • 407错误是什么 407错误怎么解决

    407错误是什么?407错误怎么解决?不少站长都遇到过407错误,下面小编将告诉大家如何处理407错误。 407错误是什么: HTTP 407错误是HTTP协议状态码的一种,表示需要代...2017-01-22
  • 406错误是什么 406错误怎么解决

    HTTP 406错误是HTTP协议状态码的一种,表示无法使用请求的内容特性来响应请求的网页。一般是指客户端浏览器不接受所请求页面的 MIME 类型。 而MIME类型是在把输出...2017-01-22
  • 410错误是什么 http 410错误怎么解决

    410错误是HTTP协议状态码的一种,本次一聚教程网将为大家详细介绍HTTP 410错误是什么,以及410错误的解决办法。 410错误是什么: HTTP 410错误是HTTP协议状态码的...2017-01-22
  • HTTP 400错误是什么 HTTP 400错误怎么解决

    每当遇到http错误代码为400,代表客户端发起的请求不符合服务器对请求的某些限制,或者请求本身存在一定的错误,那么HTTP 400错误怎么解决呢?请看下文介绍。 目前400错...2017-01-22
  • Jrebel启动失败解决方案详解

    这篇文章主要介绍了Jrebel启动失败解决方案详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-07-07
  • VSCode C++多文件编译的简单使用方法

    这篇文章主要介绍了VSCode C++多文件编译的简单使用方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2021-03-29
  • Vue3 编译流程-源码解析

    今天将从 Vue 的入口文件开始,看看声明了一个 Vue 的单文件之后是如何被 compile-core 编译核心模块编译成渲染函数的。下面小编讲解并附上代码分析展现在文章里,感兴趣的小伙伴不要错过奥...2021-09-25
  • 解决Docker中的error during connect异常情况

    这篇文章主要介绍了解决Docker中的error during connect异常情况,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-11-22
  • vscode和cmake编译多个C++文件的实现方法

    这篇文章主要介绍了vscode和cmake编译多个C++文件的实现方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-10
  • 小记一次mysql主从配置解决方案

      今天研究了个开源项目,数据库是mysql的,其中的脚本数据需要备份,由于本人的机器时mac pro,而且mac下的数据库连接工具都不怎么好用,就想着如何利用windows下的数据库连接工具使用,并做相关备份,另外windows系统下的sqlyo...2015-10-21
  • error LNK2019: 无法解析的外部符号 问题的解决办法

    error LNK2019: 无法解析的外部符号 问题的解决办法,需要的朋友可以参考一下...2020-04-25
  • 使用 C# 动态编译代码和执行的代码

    一个控制台例子, 演示了如何用 C# 动态的生成代码, 编译代码, 最后执行...2020-06-25
  • php 502 bad gateway的解决方案

    502 bad gateway是php-fpm的问题对于这个问题就是配置参数的问题了,下面我们整理了一些关于php-fpm错误问题的解决办法,具体如下。 今天升级完PHP出现了502 Bad Gat...2016-11-25
  • 关于MySQL绕过授予information_schema中对象时报ERROR 1044(4200)错误

    这篇文章主要介绍了关于MySQL绕过授予information_schema中对象时报ERROR 1044(4200)错误,本文给大家分享解决方法,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-10-17