# PHP 函数:ifx\_connect()

**URL:** <https://www.isharkfly.com/t/php-ifx-connect/3457>\
**Category:** PHP\
**Created:** [October 18, 2012, 1:55am UTC](https://www.isharkfly.com/t/php-ifx-connect/3457 "2012-10-18T01:55:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [October 18, 2012, 1:55am UTC](https://www.isharkfly.com/t/php-ifx-connect/3457/1 "2012-10-18T01:55:10Z")

</div>

打开 Informix 服务器连接。

语法: int ifx\_connect(string [database], string [userid], string [password]);

返回值: 整数

函数种类: 数据库功能

内容说明  
本函数建立与 Informix 服务器的连接。其中所有的参数都可省略。若全部参数都省略时，使用系统的 php3.ini 或是 php.ini (视 PHP 版本决定) 中 ifx.default\_host 指定的机器，或是环境变量 $INFORMIXSERVER；ifx.default\_user 为用户帐号；ifx.default\_password 为用户密码。而参数 database、userid 及 password 分别为数据库的名字、登入帐号及使用密码。当然，在使用本函数之后，尽早使用 ifx\_close() 关闭 Informix 数据库比较好。连接成功则返回连接代码，失败则返回 false 值。

使用范例

本例只有连上数据库，什么事都没做。

\<?php $conn\_id = ifx\_pconnect("mydb@ol\_srv1", "imyself", "mypassword"); ifx\_close($conn\_id); ?\>
