标签 php 下的文章

<?php
class Test{ 
    /**
    *字符串转十六进制函数
    *@pream string $str='abc';
    */
    public function strToHex($str){ 
        $hex="";
        for($i=0;$i<strlen($str);$i++)
        $hex.=dechex(ord($str[$i]));
        $hex=strtoupper($hex);
        return $hex;
    }   
     
    /**
    *十六进制转字符串函数
    *@pream string $hex='616263';
    */ 
    public function hexToStr($hex){   
        $str=""; 
        for($i=0;$i<strlen($hex)-1;$i+=2)
        $str.=chr(hexdec($hex[$i].$hex[$i+1]));
        return  $str;
    } 
}
 <span style="white-space:pre">    </span>//测试Demo效果
    $test = new Test();
    $str = '要加密的内容sxfenglei';
    $data = $test->strToHex($str); 
    echo '加密内容:要加密的内容sxfenglei <br>'.$data.'<hr>';  
 
    $output = $test->hexToStr($data);
    echo '解密内容:E8A681E58AA0E5AF86E79A84E58685E5AEB9737866656E676C6569 <br>'.$output;  
?>

PHP7.1

./configure --prefix=/usr/local/php7 --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --with-gd --with-freetype-dir=/usr/local/freetype24 --with-mcrypt

PHP5.6

yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel freetype freetype-devel jpegsrc libpng libpng-devel

创建 www 用户

groupadd www

useradd -g www -s /sbin/nologin -M www

./configure --prefix=/usr/local/php56 --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --with-gd --with-freetype-dir=/usr/local/freetype24

转一个文章(参数含义):
https://blog.csdn.net/niluchen/article/details/41513217

# 指定 php 安装目录

--prefix=/usr/local/php 

# 指定php.ini位置

--with-config-file-path=/usr/local/php/etc 

# mysql安装目录,对mysql的支持

--with-mysql=/usr/local/mysql

mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定。

--with-mysqli=/usr/local/mysql/bin/mysql_config   

整合 apache,apxs功能是使用mod_so中的LoadModule指令,加载指定模块到 apache,要求 apache 要打开SO模块

--with-apxs2=/usr/local/apache/bin/apxs 

# 选项指令 --with-iconv-dir 用于 PHP 编译时指定 iconv 在系统里的路径,否则会扫描默认路径。

--with-iconv-dir=/usr/local 

 

--with-freetype-dir   打开对freetype字体库的支持 

--with-jpeg-dir   打开对jpeg图片的支持 

--with-png-dir   打开对png图片的支持 

--with-zlib-dir   打开zlib库的支持,用于http压缩传输

--with-libxml-dir   打开libxml2库的支持

--disable-rpath    关闭额外的运行库文件 

--enable-bcmath    打开图片大小调整,用到zabbix监控的时候用到了这个模块

--enable-shmop --enable-sysvsem  这样就使得你的PHP系统可以处理相关的IPC函数了。

--enable-inline-optimization  优化线程

--with-curl    打开curl浏览工具的支持 

--with-curlwrappers    运用curl工具打开url流 

--enable-mbregex

--enable-fpm 打上PHP-fpm 补丁后才有这个参数,CGI方式安装的启动程序

--enable-mbstring    多字节,字符串的支持 

--with-mcrypt                    mcrypt算法扩展

--with-mhash                     mhash算法扩展

--with-gd    打开gd库的支持 

--enable-gd-native-ttf   支持TrueType字符串函数库

--with-openssl      openssl的支持,加密传输https时用到的

--enable-pcntl   freeTDS需要用到的,可能是链接mssql 才用到

--enable-sockets     打开 sockets 支持

--with-xmlrpc    打开xml-rpc的c语言 

--enable-zip   打开对zip的支持 

--enable-ftp   打开ftp的支持 

 

--with-bz2    打开对bz2文件的支持        

--without-iconv   关闭iconv函数,字符集间的转换 

--with-ttf     打开freetype1.*的支持,可以不加了 

--with-xsl     打开XSLT 文件支持,扩展了libXML2库 ,需要libxslt软件 

--with-gettext     打开gnu 的gettext 支持,编码库用到 

--with-pear    打开pear命令的支持,PHP扩展用的 

--enable-calendar    打开日历扩展功能

--enable-exif    图片的元数据支持 

--enable-magic-quotes    魔术引用的支持 

 

--disable-debug    关闭调试模式 

--with-mime-magic=/usr/share/file/magic.mime      魔术头文件位置

CGI方式安装才用的参数

 

--enable-fastCGI            支持fastcgi方式启动PHP

--enable-force-CGI-redirect        重定向方式启动PHP

--with-ncurses         支持ncurses 屏幕绘制以及基于文本终端的图形互动功能的动态库

--with-gmp  应该是支持一种规范

--enable-dbase                     建立DBA 作为共享模块

--with-pcre-dir=/usr/local/bin/pcre-config      perl的正则库案安装位置

--disable-dmalloc

--with-gdbm                     dba的gdbm支持

--enable-sigchild

--enable-sysvshm

--enable-zend-multibyte         支持zend的多字节

--enable-wddx

--enable-soap

./configure -prefix=/usr/local/php7 -with-config-file-path=/usr/local/php7/etc -with-mcrypt=/usr/include -enable-mysqlnd -with-gd -with-iconv -with-zlib -enable-bcmath -enable-shmop -enable-sysvsem -enable-inline-optimization -enable-mbregex -enable-fpm -enable-mbstring -enable-ftp -enable-gd-native-ttf -with-openssl -enable-pcntl -enable-sockets -with-xmlrpc -enable-zip -enable-soap -with-gettext -with-curl -with-jpeg-dir -with-freetype-dir -with-mysqli -enable-embedded-mysqli -with-pdo-mysql

https://segmentfault.com/q/1010000015379092

分析了几天,没有结果
很是蛋痛

今天终于找到问题原因:$data 变量中 存在一个同名的data的键,程序里并且进行了两次 extract($data),第一次把data中的数据导出后,就替换掉了 $data 导致第二次导出的数据就不存在了

问题是我其他有一个页面也用了data这个键名,也没有问题,就奇怪了

我开发环境,另一个页面也是存在 同键名的值 的,却没有问题


function arrayGet($array, $key, $default = null) {
    $keys = explode('.', $key);
    $a = $array;
    while (count($keys) != 0) {
        $key = array_shift($keys);
        if(!isset($a[$key])){
            return $default;
        }
        $a = $a[$key];
    }
    return $a;
}

function arraySet(&$array, $key, $value) {
    $keys = explode('.', $key);
    if (count($keys) == 1) {
        $array[$key] = $value;
        return;
    }
    $a = array();
    $b = $array;
    while (count($keys) != 0) {
        $k = array_shift($keys);
        $b = isset($b[$k]) ? $b[$k] : array();
        $a[$k] = $b;
    }
    $ka = array_keys($a);
    $a[end($ka)] = $value;
    for ($index = count($ka) - 2; $index >= 0; $index--) {
        $k = $ka[$index];
        $nextK = $ka[$index + 1];
        $a[$k] = array_merge($a[$k], array($nextK => $a[$nextK]));
    }
    $array[$ka[0]] = $a[$ka[0]];
}