CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  PHP

[求助] 如何利用PHP来读写INI文件,如API里IniFiles里的函数一样?

楼主TJey(西门俊杰)2003-05-04 19:51:33 在 Web 开发 / PHP 提问

[求助]   如何利用PHP来读写INI文件,如API里IniFiles里的函数一样?  
  请各位路过的大虾们给点点子吧,多谢了!如能实现我会加分的!  
  还有最好是一个例子!多谢了! 问题点数:0、回复次数:7Top

1 楼hurricane(随意春芳歇)回复于 2003-05-05 08:40:42 得分 0

好象没有这样方便的函数,你就自己控制好格式,再去进行文件的读写操作吧。Top

2 楼leeeel(我笑你多情)回复于 2003-05-05 08:53:45 得分 0

INI文件过时了。用XML或者别的Top

3 楼upchina(辉)回复于 2003-05-05 08:55:03 得分 0

 
   
  parse_ini_file  
  (PHP   4   )  
   
  parse_ini_file   --   Parse   a   configuration   file  
  Description  
  array   parse_ini_file   (   string   filename   [,   bool   process_sections])Top

4 楼TJey(西门俊杰)回复于 2003-05-05 11:40:31 得分 0

TO:   upchina(辉)    
  能给我读写INI的例子吗?多谢了!Top

5 楼upchina(辉)回复于 2003-05-05 22:05:12 得分 0

看手册啊!  
   
  parse_ini_file  
  (PHP   4   )  
   
  parse_ini_file   --   Parse   a   configuration   file  
  Description  
  array   parse_ini_file   (   string   filename   [,   bool   process_sections])  
   
   
  parse_ini_file()   loads   in   the   ini   file   specified   in   filename,   and   returns   the   settings   in   it   in   an   associative   array.   By   setting   the   last   process_sections   parameter   to   TRUE,   you   get   a   multidimensional   array,   with   the   section   names   and   settings   included.   The   default   for   process_sections   is   FALSE    
   
  注:   This   function   has   nothing   to   do   with   the   php.ini   file.   It   is   already   processed,   the   time   you   run   your   script.   This   function   can   be   used   to   read   in   your   own   application's   configuration   files.    
   
  注:   If   a   value   in   the   ini   file   contains   any   non-alphanumeric   characters   it   needs   to   be   enclosed   in   double-quotes   (").    
   
  注:   Since   PHP   4.2.1   this   function   is   also   affected   by   safe_mode   and   open_basedir.    
   
  The   structure   of   the   ini   file   is   similar   to   that   of   the   php.ini's.    
   
   
  警告    
  If   the   ini   file   you   are   trying   to   parse   is   malformed,   PHP   will   exit.    
     
   
  例子   1.   Contents   of   sample.ini  
   
  ;   This   is   a   sample   configuration   file  
  ;   Comments   start   with   ';',   as   in   php.ini  
   
  [first_section]  
  one   =   1  
  five   =   5  
   
  [second_section]  
  path   =   /usr/local/bin  
  URL   =   "http://www.example.com/~username"  
     
     
   
   
  例子   2.   parse_ini_file()   example  
   
  <?php  
   
  //   Parse   without   sections  
  $ini_array   =   parse_ini_file("sample.ini");  
  print_r($ini_array);  
   
  //   Parse   with   sections  
  $ini_array   =   parse_ini_file("sample.ini",   TRUE);  
  print_r($ini_array);  
   
  ?>  
     
     
   
   
  Would   produce:    
   
   
  Array  
  (  
          [one]   =>   1  
          [five]   =>   5  
          [path]   =>   /usr/local/bin  
          [URL]   =>   http://www.example.com/~username  
  )  
  Array  
  (  
          [first_section]   =>   Array  
                  (  
                          [one]   =>   1  
                          [five]   =>   5  
                  )  
   
          [second_section]   =>   Array  
                  (  
                          [path]   =>   /usr/local/bin  
                          [URL]   =>   http://www.example.com/~username  
                  )  
   
  )  
     
  Top

6 楼lapmx(e+)回复于 2003-05-05 23:34:56 得分 0

好文Top

7 楼TJey(西门俊杰)回复于 2003-05-10 18:19:57 得分 0

TO:   upchina(辉)    
   
  但这个Ex.只没有表明能写这个INI文件呀,还有如果在Ini里遇到“|”而php   好像不能完整地读出来!你试试看吧!Top

相关问题

  • PHP的copy函数
  • PHP 函数 转成 ASP函数
  • PHP函数fopen的问题
  • php处理日期函数!
  • 读*.ini文件用哪一个函数。
  • API函数读取INI文件
  • PHP中的Pack()函数,Java有哪个函数与之对应???
  • PHP中可以调用c函数吗?
  • php中使用函数的问题
  • 一个有关php图形函数

关键词

  • 函数
  • 文件
  • php
  • ini
  • parse
  • 读写
  • section
  • 例子
  • five
  • array

得分解答快速导航

  • 帖主:TJey

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo