php-5.5.14 添加mssql模块

系统版本: centos6
php版本:php-5.5.14

[root@localhost ~]# cd php-5.5.14/ext/mssql
[root@localhost mssql]# /usr/local/php/bin/phpize
[root@localhost mssql]# ./configure --with-php-config=/usr/local/php/bin/php-config

报错:

configure: error: Cannot find FreeTDS in known installation directories

FreeTDS是一个程序库,可以实现在Linux系统下访问微软的SQL数据库!

下载TDS:

[root@localhost ~]# wget -c ftp://ftp.freetds.org/pub/freetds/stable/freetds-0.95.89.tar.gz
[root@localhost freetds-0.95.89]# ./configure --prefix=/usr/local/freetds
[root@localhost freetds-0.95.89]# make &&make install

回到php扩展mssql目录:

[root@localhost mssql]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-mssql=/usr/local/freetds/
[root@localhost mssql]# make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/

编辑php.ini载入模块

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/"
extension = "mssql.so"

重启服务。
通过phpinfo就可以看到mssql模块了。

failed to start lsb:bring up/down

rhel7删掉部分配置参数。

TYPE=Ethernet
BOOTPROTO=static
NAME=eno16777736
ONBOOT=yes
IPADDR=192.168.1.11
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=202.102.134.68
HWADDR=00:0c:29:4c:89:e4
把HWADDR删掉了,结果网络服务启动不了,百度出来说没有HWADDR参数,刚才确实删掉了,
用 ip a查看网卡mac地址,写入配置文件解决。

php获取文件名扩展两种方法

// 文件
$file = '/admin/login/index.php';

// 方法1
// 1 获取文件名
$a = basename($file);
// 2 获取扩展名
$b = strrchr($a, '.');
// 3 去掉扩展名中的点
$c = substr($b, 1);
echo $c . "<br/>";

//合并起来
echo substr(strrchr(basename($file), '.'), 1) . "<br/>";


// 方法2 利用 pathinfo
var_dump(pathinfo($file));

array(4) {
  'dirname' =>
  string(12) "/admin/login"
  'basename' =>
  string(9) "index.php"
  'extension' =>
  string(3) "php"
  'filename' =>
  string(5) "index"
}

可以看到是一个数据,直接调key
echo pathinfo($file)['extension'];