- 浏览: 2551158 次
- 性别:
- 来自: 深圳
-
文章分类
- 全部博客 (676)
- linux运维 (157)
- php (65)
- mysql (78)
- nginx (27)
- apche (18)
- framework (6)
- windows (9)
- IDE工具 (23)
- struts2 (7)
- java (13)
- 移动互联网 (14)
- memcache redis (23)
- shell基础/命令/语法 (37)
- shell (50)
- puppet (4)
- C (11)
- python (9)
- 产品经理 (27)
- Sphinx (4)
- svn (12)
- 设计构建 (12)
- 项目管理 (44)
- SEO (1)
- 网站架构 (26)
- 审时度势 (42)
- 网络 (14)
- 激发事业[书&视频] (81)
- 其它 (12)
- 摄影 (8)
- android (21)
最新评论
-
zhongmin2012:
原文的书在哪里
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器 -
renzhengzhi:
你好,请问个问题,从master同步数据到slave的时候,s ...
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器 -
ibc789:
你好,看了你的文章,我想请教个问题, 我在用 redis的时候 ...
redis 的两种持久化方式及原理 -
iijjll:
写得非常好
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器 -
iijjll:
写得非常好
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器
为了使自己的程序在不同的平台中拥有更好的兼容性,很多时候我们都要获取当前Php的运行环境参数。
比如我们常用到的:
获取 magic_quotes_gpc 状态,来决定当表单提交时我们是否转义(addslashes)数据;
设定 max_execution_time 来延长 程序的执行时间;
设定 error_reporting 使自己的项目在开发与运营阶段切换;
设定 memory_limit 加大内存等等…
- ini_set (string varname, string newvalue ) : //设定环境配置的参数
- ini_get (string varname) : //获取环境配置的参数
ini_set(string varname, string newvalue ) : //设定环境配置的参数 ini_get(string varname) : //获取环境配置的参数
PHP ini_set函数是设置选项中的值,在执行函数后生效,脚本结束的时候,这个设置也失效。不是所有的选项都能被改函数设置的。具体那些值能够设置,可以查看手册中的列表。
就是能够设置php.ini中的选项值比如,display_error选项关闭 了,但是你要显示程序中的错误信息,方便你调试程序,那么就可以使用PHP ini_set函数:
- ini_set ( 'display_errors' , 'On' );
ini_set('display_errors', 'On');
那么在你这个页面的程序都会显示错误信息了,而且你还可以使用error_reporting来设置显示的错误信息级别。
如果你需要增加脚本执行时间,那么可以设置:
- ini_set ( 'max_execution_time' , '180' );
ini_set('max_execution_time', '180');
那么脚本执行时间就由默认的30秒变为180秒,当然,你也可以使用set_time_limit()来设置。
其实你把PHP ini_set函数和ini_get结合使的话,非常好。比如你想在配置文件里添加自己的包含文件路径,但是你有没有权限更改php.ini,那么你可以 结合两个函数:
- ini_set ( 'include_path' , ini_get ( 'include_path' ). ':/your_include_dir:' );
ini_set('include_path',ini_get('include_path').':/your_include_dir:');
PHP配置函数ini_get()相信很多人都使过,就是获取配置文件中某一个选项的值,如果是true值就返回1,如果是false值就返回0,字符串就返回字符串。
比如手册中的例子:
- <?php
- /* Our php.ini contains the following settings: display_errors = On register_globals = Off post_max_size = 8M */
- echo 'display_errors = ' . ini_get ( 'display_errors' ) . " " ; //显示错误是否打开
- echo 'register_globals = ' . ini_get ( 'register_globals' ) . " " ; //全局变量是否打开
- echo 'post_max_size = ' . ini_get ( 'post_max_size' ) . " " ; //最多能提交的文件大小
- echo 'post_max_size+1 = ' . ( ini_get ( 'post_max_size' )+1) . " " ;
- ?>
<?php /* Our php.ini contains the following settings: display_errors = On register_globals = Off post_max_size = 8M */ echo 'display_errors = ' . ini_get('display_errors') . " "; //显示错误是否打开 echo 'register_globals = ' . ini_get('register_globals') . " "; //全局变量是否打开 echo 'post_max_size = ' . ini_get('post_max_size') . " "; //最多能提交的文件大小 echo 'post_max_size+1 = ' . (ini_get('post_max_size')+1) . " "; ?>
输出:
display_errors = 1
register_globals = 0
post_max_size = 8M
post_max_size+1 = 9
PHP配置函数ini_get()主要是为了获取配置文件,可以方便你很多操作。 比如你想操作字符串过滤,但是又不清楚 magic_quotes_gpc有没有打开,所以你就可以这样写一个函数:
- <?php
- /* 字符串过滤函数 */
- function stringFilter( $str ) {
- if ( ini_get ( 'magic_quotes_gpc)' ) { return $str ; } else { return addslashes ( $str ); }
- }
- ?>
<?php /* 字符串过滤函数 */ function stringFilter($str) { if (ini_get('magic_quotes_gpc)') { return $str; } else { return addslashes($str); } } ?>
当然,如果你无法知道你的全局变量是否打开,也可以定制这样的函数:
- <?php
- /* 变量检测函数 */
- function getGetVar( $var ) {
- if ( ini_set ( 'register_gobals' )){ return $var ; } else { return $_GET [ 'var' ]; }
- }
- ?>
<?php /* 变量检测函数 */ function getGetVar($var) { if (ini_set('register_gobals')){ return $var; } else { return $_GET['var']; } } ?>
当然,你可以用PHP配置函数ini_get()做很多用途,自己慢慢体会。
com.allow_dcom | "0" | PHP_INI_SYSTEM |
com.autoregister_typelib | "0" | PHP_INI_SYSTEM |
com.autoregister_verbose | "0" | PHP_INI_SYSTEM |
com.autoregister_casesensitive | "1" | PHP_INI_SYSTEM |
com.typelib_file | "" | PHP_INI_SYSTEM |
crack.default_dictionary | NULL | PHP_INI_SYSTEM |
exif.encode_unicode | "ISO-8859-15" | PHP_INI_ALL |
exif.decode_unicode_motorola | "UCS-2BE" | PHP_INI_ALL |
exif.decode_unicode_intel | "UCS-2LE" | PHP_INI_ALL |
exif.encode_jis | "" | PHP_INI_ALL |
exif.decode_jis_motorola | "JIS" | PHP_INI_ALL |
exif.decode_jis_intel | "JIS" | PHP_INI_ALL |
fbsql.allow_persistent | "1" | PHP_INI_SYSTEM |
fbsql.generate_warnings | "0" | PHP_INI_SYSTEM |
fbsql.autocommit | "1" | PHP_INI_SYSTEM |
fbsql.max_persistent | "-1" | PHP_INI_SYSTEM |
fbsql.max_links | "128" | PHP_INI_SYSTEM |
fbsql.max_connections | "128" | PHP_INI_SYSTEM |
fbsql.max_results | "128" | PHP_INI_SYSTEM |
fbsql.batchSize | "1000" | PHP_INI_SYSTEM |
fbsql.default_host | NULL | PHP_INI_SYSTEM |
fbsql.default_user | "_SYSTEM" | PHP_INI_SYSTEM |
fbsql.default_password | "" | PHP_INI_SYSTEM |
fbsql.default_database | "" | PHP_INI_SYSTEM |
fbsql.default_database_password | "" | PHP_INI_SYSTEM |
hwapi.allow_persistent | "0" | PHP_INI_SYSTEM |
hyperwave.allow_persistent | "0" | PHP_INI_SYSTEM |
hyperwave.default_port | "418" | PHP_INI_ALL |
iconv.input_encoding | ICONV_INPUT_ENCODING | PHP_INI_ALL |
iconv.output_encoding | ICONV_OUTPUT_ENCODING | PHP_INI_ALL |
iconv.internal_encoding | ICONV_INTERNAL_ENCODING | PHP_INI_ALL |
ifx.allow_persistent | "1" | PHP_INI_SYSTEM |
ifx.max_persistent | "-1" | PHP_INI_SYSTEM |
ifx.max_links | "-1" | PHP_INI_SYSTEM |
ifx.default_host | NULL | PHP_INI_SYSTEM |
ifx.default_user | NULL | PHP_INI_SYSTEM |
ifx.default_password | NULL | PHP_INI_SYSTEM |
ifx.blobinfile | "1" | PHP_INI_ALL |
ifx.textasvarchar | "0" | PHP_INI_ALL |
ifx.byteasvarchar | "0" | PHP_INI_ALL |
ifx.charasvarchar | "0" | PHP_INI_ALL |
ifx.nullformat | "0" | PHP_INI_ALL |
ingres.allow_persistent | "1" | PHP_INI_SYSTEM |
ingres.max_persistent | "-1" | PHP_INI_SYSTEM |
ingres.max_links | "-1" | PHP_INI_SYSTEM |
ingres.default_database | NULL | PHP_INI_ALL |
ingres.default_user | NULL | PHP_INI_ALL |
ingres.default_password | NULL | PHP_INI_ALL |
ibase.allow_persistent | "1" | PHP_INI_SYSTEM |
ibase.max_persistent | "-1" | PHP_INI_SYSTEM |
ibase.max_links | "-1" | PHP_INI_SYSTEM |
ibase.default_user | NULL | PHP_INI_ALL |
ibase.default_password | NULL | PHP_INI_ALL |
ibase.timestampformat | "%m/%d/%Y%H:%M:%S" | PHP_INI_ALL |
ibase.dateformat | "%m/%d/%Y" | PHP_INI_ALL |
ibase.timeformat | "%H:%M:%S" | PHP_INI_ALL |
java.class.path | NULL | PHP_INI_ALL |
java.home | NULL | PHP_INI_ALL |
java.library.path | NULL | PHP_INI_ALL |
java.library | JAVALIB | PHP_INI_ALL |
java.library | NULL | PHP_INI_ALL |
ldap.max_links | "-1" | PHP_INI_SYSTEM |
mbstring.detect_order | NULL | PHP_INI_ALL |
mbstring.http_input | NULL | PHP_INI_ALL |
mbstring.http_output | NULL | PHP_INI_ALL |
mbstring.internal_encoding | NULL | PHP_INI_ALL |
mbstring.substitute_character | NULL | PHP_INI_ALL |
mbstring.func_overload | "0" | PHP_INI_SYSTEM |
mcrypt.algorithms_dir | NULL | PHP_INI_ALL |
mcrypt.modes_dir | NULL | PHP_INI_ALL |
mime_magic.magicfile | "/usr/share/misc/magic.mime" | PHP_INI_SYSTEM |
mssql.allow_persistent | "1" | PHP_INI_SYSTEM |
mssql.max_persistent | "-1" | PHP_INI_SYSTEM |
mssql.max_links | "-1" | PHP_INI_SYSTEM |
mssql.max_procs | "25" | PHP_INI_ALL |
mssql.min_error_severity | "10" | PHP_INI_ALL |
mssql.min_message_severity | "10" | PHP_INI_ALL |
mssql.compatability_mode | "0" | PHP_INI_ALL |
mssql.connect_timeout | "5" | PHP_INI_ALL |
mssql.timeout | "60" | PHP_INI_ALL |
mssql.textsize | "-1" | PHP_INI_ALL |
mssql.textlimit | "-1" | PHP_INI_ALL |
mssql.batchsize | "0" | PHP_INI_ALL |
mssql.datetimeconvert | "1" | PHP_INI_ALL |
mssql.secure_connection | "0" | PHP_INI_SYSTEM |
mysql.allow_persistent | "1" | PHP_INI_SYSTEM |
mysql.max_persistent | "-1" | PHP_INI_SYSTEM |
mysql.max_links | "-1" | PHP_INI_SYSTEM |
mysql.default_host | NULL | PHP_INI_ALL |
mysql.default_user | NULL | PHP_INI_ALL |
mysql.default_password | NULL | PHP_INI_ALL |
mysql.default_port | NULL | PHP_INI_ALL |
mysql.default_socket | NULL | PHP_INI_ALL |
ncurses.value | "42" | PHP_INI_ALL |
ncurses.string | "foobar" | PHP_INI_ALL |
odbc.allow_persistent | "1" | PHP_INI_SYSTEM |
odbc.max_persistent | "-1" | PHP_INI_SYSTEM |
odbc.max_links | "-1" | PHP_INI_SYSTEM |
odbc.default_db | NULL | PHP_INI_ALL |
odbc.default_user | NULL | PHP_INI_ALL |
odbc.default_pw | NULL | PHP_INI_ALL |
odbc.defaultlrl | "4096" | PHP_INI_ALL |
odbc.defaultbinmode | "1" | PHP_INI_ALL |
odbc.check_persistent | "1" | PHP_INI_SYSTEM |
pfpro.defaulthost | "test.signio.com" | |
pfpro.defaulthost | "test-payflow.verisign.com" | |
pfpro.defaultport | "443" | PHP_INI_ALL |
pfpro.defaulttimeout | "30" | PHP_INI_ALL |
pfpro.proxyaddress | "" | PHP_INI_ALL |
pfpro.proxyport | "" | PHP_INI_ALL |
pfpro.proxylogon | "" | PHP_INI_ALL |
pfpro.proxypassword | "" | PHP_INI_ALL |
pgsql.allow_persistent | "1" | PHP_INI_SYSTEM |
pgsql.max_persistent | "-1" | PHP_INI_SYSTEM |
pgsql.max_links | "-1" | PHP_INI_SYSTEM |
pgsql.auto_reset_persistent | "0" | PHP_INI_SYSTEM |
pgsql.ignore_notice | "0" | PHP_INI_ALL |
pgsql.log_notice | "0" | PHP_INI_ALL |
session.save_path | "/tmp" | PHP_INI_ALL |
session.name | "PHPSESSID" | PHP_INI_ALL |
session.save_handler | "files" | PHP_INI_ALL |
session.auto_start | "0" | PHP_INI_ALL |
session.gc_probability | "1" | PHP_INI_ALL |
session.gc_divisor | "100" | PHP_INI_ALL |
session.gc_maxlifetime | "1440" | PHP_INI_ALL |
session.serialize_handler | "php" | PHP_INI_ALL |
session.cookie_lifetime | "0" | PHP_INI_ALL |
session.cookie_path | "/" | PHP_INI_ALL |
session.cookie_domain | "" | PHP_INI_ALL |
session.cookie_secure | "" | PHP_INI_ALL |
session.use_cookies | "1" | PHP_INI_ALL |
session.use_only_cookies | "0" | PHP_INI_ALL |
session.referer_check | "" | PHP_INI_ALL |
session.entropy_file | "" | PHP_INI_ALL |
session.entropy_length | "0" | PHP_INI_ALL |
session.cache_limiter | "nocache" | PHP_INI_ALL |
session.cache_expire | "180" | PHP_INI_ALL |
session.use_trans_sid | "0" | PHP_INI_SYSTEM PHP_INI_PERDIR |
session.encode_sources | "globals,track" | PHP_INI_ALL |
assert.active | "1" | PHP_INI_ALL |
assert.bail | "0" | PHP_INI_ALL |
assert.warning | "1" | PHP_INI_ALL |
assert.callback | NULL | PHP_INI_ALL |
assert.quiet_eval | "0" | PHP_INI_ALL |
safe_mode_protected_env_vars | SAFE_MODE_PROTECTED_ENV_VARS | PHP_INI_SYSTEM |
safe_mode_allowed_env_vars | SAFE_MODE_ALLOWED_ENV_VARS | PHP_INI_SYSTEM |
url_rewriter.tags | "a=href,area=href, frame=src, form=fakeentry" |
PHP_INI_ALL |
sybct.allow_persistent | "1" | PHP_INI_SYSTEM |
sybct.max_persistent | "-1" | PHP_INI_SYSTEM |
sybct.max_links | "-1" | PHP_INI_SYSTEM |
sybct.min_server_severity | "10" | PHP_INI_ALL |
sybct.min_client_severity | "10" | PHP_INI_ALL |
sybct.hostname | NULL | PHP_INI_ALL |
vpopmail.directory | "" | PHP_INI_ALL |
zlib.output_compression | "0" | PHP_INI_SYSTEM PHP_INI_PERDIR |
zlib.output_compression_level | "-1" | PHP_INI_ALL |
define_syslog_variables | "0" | PHP_INI_ALL |
highlight.bg | HL_BG_COLOR | PHP_INI_ALL |
highlight.comment | HL_COMMENT_COLOR | PHP_INI_ALL |
highlight.default | HL_DEFAULT_COLOR | PHP_INI_ALL |
highlight.html | HL_HTML_COLOR | PHP_INI_ALL |
highlight.keyword | HL_KEYWORD_COLOR | PHP_INI_ALL |
highlight.string | HL_StrING_COLOR | PHP_INI_ALL |
allow_call_time_pass_reference | "1" | PHP_INI_SYSTEM PHP_INI_PERDIR |
asp_tags | "0" | PHP_INI_SYSTEM PHP_INI_PERDIR |
display_errors | "1" | PHP_INI_ALL |
display_startup_errors | "0" | PHP_INI_ALL |
enable_dl | "1" | PHP_INI_SYSTEM |
expose_php | "1" | PHP_INI_SYSTEM |
html_errors | "1" | PHP_INI_ALL |
xmlrpc_errors | "0" | PHP_INI_SYSTEM |
xmlrpc_error_number | "0" | PHP_INI_ALL |
ignore_user_abort | "0" | PHP_INI_ALL |
implicit_flush | "0" | PHP_INI_ALL |
log_errors | "0" | PHP_INI_ALL |
log_errors_max_len | "1024" | PHP_INI_ALL |
ignore_repeated_errors | "0" | PHP_INI_ALL |
ignore_repeated_source | "0" | PHP_INI_ALL |
magic_quotes_gpc | "1" | PHP_INI_PERDIR PHP_INI_SYSTEM |
magic_quotes_runtime | "0" | PHP_INI_ALL |
magic_quotes_sybase | "0" | PHP_INI_ALL |
output_buffering | "0" | PHP_INI_PERDIR PHP_INI_SYSTEM |
output_handler | NULL | PHP_INI_PERDIR PHP_INI_SYSTEM |
register_argc_argv | "1" | PHP_INI_PERDIR PHP_INI_SYSTEM |
register_globals | "0" | PHP_INI_PERDIR PHP_INI_SYSTEM |
safe_mode | "1" | PHP_INI_SYSTEM |
safe_mode | "0" | PHP_INI_SYSTEM |
safe_mode_include_dir | NULL | PHP_INI_SYSTEM |
safe_mode_gid | "0" | PHP_INI_SYSTEM |
short_open_tag | DEFAULT_SHORT_OPEN_TAG | PHP_INI_SYSTEM PHP_INI_PERDIR |
sql.safe_mode | "0" | PHP_INI_SYSTEM |
track_errors | "0" | PHP_INI_ALL |
y2k_compliance | "0" | PHP_INI_ALL |
unserialize_callback_func | NULL | PHP_INI_ALL |
arg_separator.output | "&" | PHP_INI_ALL |
arg_separator.input | "&" | PHP_INI_SYSTEM PHP_INI_PERDIR |
auto_append_file | NULL | PHP_INI_SYSTEM PHP_INI_PERDIR |
auto_prepend_file | NULL | PHP_INI_SYSTEM PHP_INI_PERDIR |
doc_root | NULL | PHP_INI_SYSTEM |
default_charset | SAPI_DEFAULT_CHARSET | PHP_INI_ALL |
default_mimetype | SAPI_DEFAULT_MIMETYPE | PHP_INI_ALL |
error_log | NULL | PHP_INI_ALL |
extension_dir | PHP_EXTENSION_DIR | PHP_INI_SYSTEM |
gpc_order | "GPC" | PHP_INI_ALL |
include_path | PHP_INCLUDE_PAth | PHP_INI_ALL |
max_execution_time | "30" | PHP_INI_ALL |
open_basedir | NULL | PHP_INI_SYSTEM |
safe_mode_exec_dir | "1" | PHP_INI_SYSTEM |
upload_max_filesize | "2M" | PHP_INI_SYSTEM PHP_INI_PERDIR |
file_uploads | "1" | PHP_INI_SYSTEM |
post_max_size | "8M" | PHP_INI_SYSTEM PHP_INI_PERDIR |
upload_tmp_dir | NULL | PHP_INI_SYSTEM |
user_dir | NULL | PHP_INI_SYSTEM |
variables_order | NULL | PHP_INI_ALL |
error_append_string | NULL | PHP_INI_ALL |
error_prepend_string | NULL | PHP_INI_ALL |
SMTP | "localhost" | PHP_INI_ALL |
smtp_port | 25 | PHP_INI_ALL |
browscap | NULL | PHP_INI_SYSTEM |
error_reporting | NULL | PHP_INI_ALL |
memory_limit | "8M" | PHP_INI_ALL |
precision | "14" | PHP_INI_ALL |
sendmail_from | NULL | PHP_INI_ALL |
sendmail_path | DEFAULT_SENDMAIL_PAth | PHP_INI_SYSTEM |
disable_classes | "" | php.ini only |
disable_functions | "" | php.ini only |
allow_url_fopen | "1" | PHP_INI_ALL |
always_populate_raw_post_data | "0" | PHP_INI_SYSTEM PHP_INI_PERDIR |
xbithack | "0" | PHP_INI_ALL |
engine | "1" | PHP_INI_ALL |
last_modified | "0" | PHP_INI_ALL |
child_terminate | "0" | PHP_INI_ALL |
async_send | "0" | PHP_INI_ALL |
可操作范围见下表:
PHP_INI_USER | 1 | Entry can be set in user scripts |
PHP_INI_PERDIR | 2 | Entry can be set in php.ini, .htaccess or httpd.conf |
PHP_INI_SYSTEM | 4 | Entry can be set in php.ini or httpd.conf |
PHP_INI_ALL | 7 | Entry can be set anywhere |
PHP_INI_USER | 1 | 该项目可以在用户脚本中设定 |
PHP_INI_PERDIR | 2 | 该项目可以在 php.ini ,.htaccess 或者 httpd.conf 中设定 |
PHP_INI_SYSTEM | 4 | 该项目可以在 php.ini 或 httpd.conf 中设定 |
PHP_INI_ALL | 7 | 该项目可以在任何地方设定 |
发表评论
-
wamp 升级php apache mysql
2014-02-18 14:30 1214wamp对于日常开发来说会增添非常大的方便 但是对于集成 ... -
[被震撼到了]我的2009年自我反省【也名10问PHP程序员】php程序员进阶篇
2012-10-29 11:22 10191.首先看了PHP的源码API函数 ,对于许多口水仗的争论一 ... -
五种常见的PHP设计模式
2012-08-15 13:37 1113原文地址:http://www.ibm.com/develop ... -
PHP的Realpath Cache
2012-07-03 09:53 3796PHP的缓存有很多种,包括输出缓冲(ob系列函数),opcod ... -
nginx+php-fmp 内存不释放
2012-06-20 11:01 5252由于服务器只有600M的内 ... -
[转]探究php底层运行机制
2012-04-17 14:36 2106http://www.myext.cn/Article/921 ... -
APC 缓存
2012-04-16 16:22 6135APC主要有两个作用,一是将php的编译缓存保存在共享内存中, ... -
【汇总】PHP-FPM 配置优化
2012-02-25 11:41 17400http://www.linuxidc.com/Linux/2 ... -
【推荐转载】谁贪占了我的系统资源 php-fpm
2012-02-16 14:12 1376测试人员向我们反映:在Facebook平台的游戏比其它平台 ... -
php代码性能分析工具:XHProf
2012-01-30 15:11 4913http://www.ooso.net/archives/52 ... -
神奇的Fastcgi_Finish_Request
2012-01-17 10:52 1267当PHP运行在FastCGI模式时,PHP FPM提供了一个名 ... -
PHP Warning: Xdebug MUST be loaded as a Zend extension in Unknown on line 0 解决办法
2011-11-07 17:18 3410;extension=php_xdebug.dll z ... -
【转】php 程序员
2011-11-05 12:01 959http://www.blags.org/php-pro ... -
cookies之PHPSESSID
2011-10-24 21:52 2961// 设置str function get_cooki ... -
并发同步
2011-10-11 14:26 1464============================= ... -
PHP核心编译配置选项列表
2011-09-15 11:21 1242PHP 的编译配置详细选项 ... -
Hudson_CI:PHP持续集成
2011-09-09 16:29 3107一、持续集成的概念 概念网上很多了,这里就不再详细说了。 ... -
try{}catch{}
2011-07-22 15:13 1232<?php /* 检测(try)、抛出(th ... -
PHP内存溢出Allowed memory size of 解决办法
2011-07-01 12:57 20627============================All ... -
?php消息队列
2011-06-22 09:45 2453php-通过共享内存实现消息队列和进程通信的两个类 h ...
相关推荐
本文实例讲述了PHP中ini_set与ini_get的用法。分享给大家供大家参考。具体如下: PHP ini_set函数。 PHP ini_set函数是设置选项中的值,在执行函数后生效,脚本结束的时候,这个设置也失效。不是所有的选项都能被该...
在某些情况下,如果我们需要获取php.ini文件中所有配置项的值,可以使用ini_get的加强函数ini_get_all()。这个函数会返回一个数组,包含当前环境中所有的配置项及其值。通过这种方式,我们可以详细了解当前PHP环境的...
要查看哪些配置项可以被修改,可以查阅PHP官方手册或使用`ini_get_all()`函数获取所有可设置的配置项及其当前值。 3. **常见设置示例**: - `memory_limit`:此设置用于限制PHP脚本可以使用的最大内存,单位可以是...
例如,你可以创建一个函数`load_config()`来加载ini文件,然后提供其他函数如`get_setting()`和`set_setting()`来处理具体的配置项。 在提供的`inifileparser`压缩包中,可能包含了示例代码或测试用例,展示了如何...
在开发PHP应用时,正确地理解和使用ini_get()函数对于配置项的查询非常关键,而ini_get_all()和ini_set()则提供了获取和设置配置项更灵活的方式。这些函数在进行系统配置和优化时,能够提供有力的支持,帮助开发者...
3. **ini_get_all()**:此函数返回一个包含所有配置设置及其值的关联数组。每个配置项都有三个键:`global_value`表示全局配置值,`local_value`表示脚本级别的配置值,`access`表示配置项的访问级别。这个函数在...
3. `ini_get_section(const char *filename, const char *section, char *buffer, int size)`: 读取指定文件和节的数据,将其存储到`buffer`中。 4. `ini_set_section(FILE *fp, const char *section)`: 写入或创建...
"INI_file_TEST.rar_配置文件"是一个示例,展示了如何使用INI文件来存储并读取应用的配置参数,特别是与界面尺寸相关的设置,如主窗体的长宽高。 INI文件是一种常见的配置文件格式,源自早期的Windows操作系统。它...
在Linux操作系统中,INI文件是一种常见的配置文件格式,它以键值对的形式存储数据,通常用于软件设置。本文将深入探讨如何使用C语言在Linux环境下对INI文件进行读写操作,以及 ini-manager-v1.02 这个库提供的功能。...
- 获取节:调用`ini_get_section()`获取指定节的信息。 - 获取键值对:通过`ini_get()`或`ini_getl()`获取特定键的值,其中`ini_getl()`可以处理包含换行符的值。 - 错误处理:`ini_error()`返回最近的错误信息。...
- 由于`get_cfg_var()`直接读取配置文件,而在某些情况下可能涉及到文件I/O操作,因此在性能上可能略逊于`ini_get()`,因为后者直接使用内存中的配置信息。 除了这两个函数,还有`ini_get_all()`函数值得一提。它...
然而,在PHP 5.3版本之后,增加了php_ini_get_configuration_hash接口,使得任何PHP扩展都能够直接访问configuration_hash,从而让配置信息的管理和修改变得更加灵活和开放。 需要注意的是,php.ini文件支持以数组...
在Linux操作系统中,通常我们使用文本文件来存储配置信息,其中INI文件是一种常见的格式,它以键值对的形式组织数据,易于人阅读和编写。本文将深入探讨如何在Linux环境下编写C程序来读取和写入INI文件。我们将基于...
本文将详细讲解如何在编程中实现对ini配置文件的读写操作,以及提供源码打包的相关知识。 一、ini文件格式 ini文件主要由节(Section)、键(Key)和值(Value)组成,其基本结构如下: ```ini [Section1] Key1=...
本文将详细介绍PHP中与配置文件操作密切相关的四个函数:ini_get、ini_set、ini_get_all和ini_restore,以及它们在实际应用中的作用。 1. ini_get() 函数: ini_get() 是用于获取PHP配置文件(php.ini)中指定选项...
总结来说,PHP的ini_get()、ini_set()、ini_get_all()和ini_restore()函数提供了一种灵活的方式来在运行时获取和改变配置信息。开发者可以利用这些函数来适应不同的运行环境,实现更加动态的配置管理。然而,需要...
ini文件是一种常见的配置文件格式,主要用于存储程序的设置和参数,因为它的结构简单、易于读写,被广泛应用于各种软件中。本篇文章将详细介绍如何进行ini文件的读写操作,并结合一个实例——TestIni,来深入理解这...
本文将详细分析四个主要的`ini`函数:`ini_get`、`ini_set`、`ini_get_all`和`ini_restore`,以及它们在实际开发中的应用。 1. `ini_get()`: `ini_get()`函数用于获取`php.ini`配置文件中指定选项的当前值。它...