PHP函数库分类三十五.docx

上传人:b****6 文档编号:7943517 上传时间:2023-05-12 格式:DOCX 页数:8 大小:18.53KB
下载 相关 举报
PHP函数库分类三十五.docx_第1页
第1页 / 共8页
PHP函数库分类三十五.docx_第2页
第2页 / 共8页
PHP函数库分类三十五.docx_第3页
第3页 / 共8页
PHP函数库分类三十五.docx_第4页
第4页 / 共8页
PHP函数库分类三十五.docx_第5页
第5页 / 共8页
PHP函数库分类三十五.docx_第6页
第6页 / 共8页
PHP函数库分类三十五.docx_第7页
第7页 / 共8页
PHP函数库分类三十五.docx_第8页
第8页 / 共8页
亲,该文档总共8页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

PHP函数库分类三十五.docx

《PHP函数库分类三十五.docx》由会员分享,可在线阅读,更多相关《PHP函数库分类三十五.docx(8页珍藏版)》请在冰点文库上搜索。

PHP函数库分类三十五.docx

PHP函数库分类三十五

PHP函数库分类三十五

10.PHP选项/信息函数列表7

·restore_include_path -Restoresthevalueoftheinclude_pathconfigurationoption

restore_include_path

(PHP4>=4.3.0,PHP5)

restore_include_path — Restoresthevalueoftheinclude_pathconfigurationoption

说明

void restore_include_path ( void )

Restorestheinclude_pathconfigurationoptionbacktoitsoriginalmastervalueassetin php.ini

返回值

没有返回值。

范例

Example#1 restore_include_path() example

php

echo get_include_path();  // .:

/usr/local/lib/php

set_include_path('/inc');

echo get_include_path();  // /inc

// Works as of PHP 4.3.0

restore_include_path();

// Works in all PHP versions

ini_restore('include_path');

echo get_include_path();  // .:

/usr/local/lib/php

?

>

·set_include_path -Setstheinclude_pathconfigurationoption

set_include_path

(PHP4>=4.3.0,PHP5)

set_include_path — Setstheinclude_pathconfigurationoption

说明

string set_include_path ( string $new_include_path )

Setstheinclude_pathconfigurationoptionforthedurationofthescript.

参数

new_include_path

Thenewvaluefortheinclude_path

返回值

Returnstheoldinclude_pathonsuccess或者在失败时返回 FALSE.

范例

Example#1 set_include_path() example

php

// Works as of PHP 4.3.0

set_include_path('/usr/lib/pear');

// Works in all PHP versions

ini_set('include_path', '/usr/lib/pear');

?

>

Example#2Addingtotheincludepath

Makinguseofthe PATH_SEPARATOR constant,itispossibletoextendtheincludepathregardlessoftheoperatingsystem.

Inthisexampleweadd /usr/lib/pear totheendoftheexisting include_path.

php

$path = '/usr/lib/pear';

set_include_path(get_include_path() . PATH_SEPARATOR . $path);

?

>

·set_magic_quotes_runtime -Setsthecurrentactiveconfigurationsettingofmagic_quotes_runtime

set_magic_quotes_runtime

(PHP4,PHP5)

set_magic_quotes_runtime — Setsthecurrentactiveconfigurationsettingofmagic_quotes_runtime

说明

bool set_magic_quotes_runtime ( bool $new_setting )

Setthecurrentactiveconfigurationsettingofmagic_quotes_runtime.

Warning

自PHP5.3.0起,已经废弃此函数。

强烈建议不要应用此函数。

参数

new_setting

FALSE foroff, TRUE foron.

返回值

成功时返回 TRUE,或者在失败时返回 FALSE.

范例

Example#1 set_magic_quotes_runtime() example

php

// Create a temporary file pointer

$fp = tmpfile();

// Write some data to the pointer

fwrite($fp, ''PHP' is a Recursive acronym');

// Without magic_quotes_runtime

rewind($fp);

set_magic_quotes_runtime(false);

echo 'Without magic_quotes_runtime:

 ' . fread($fp, 64), PHP_EOL;

// With magic_quotes_runtime

rewind($fp);

set_magic_quotes_runtime(true);

echo 'With magic_quotes_runtime:

 ' . fread($fp, 64), PHP_EOL;

// Clean up

fclose($fp);

?

>

以上例程会输出:

Withoutmagic_quotes_runtime:

'PHP'isaRecursiveacronym

Withmagic_quotes_runtime:

'PHP'isaRecursiveacronym

·set_time_limit -设置脚本最大执行时间

set_time_limit

(PHP4,PHP5)

set_time_limit — 设置脚本最大执行时间

说明

void set_time_limit ( int $seconds )

设置允许脚本运行的时间,单位为秒。

如果超过了此设置,脚本返回一个致命的错误。

默认值为30秒,或者是在php.ini的max_execution_time被定义的值,如果此值存在。

当此函数被调用时,set_time_limit()会从零开始重新启动超时计数器。

换句话说,如果超时默认是30秒,同时,脚本中又设置了25秒,如 set_time_limit(20)。

那么,脚本在超时之前可运行总共时间为45秒。

参数

seconds

最大的执行时间,单位为秒。

如果设置为0(零),没有时间方面的限制。

返回值

没有返回值。

注释

Warning

当php运行于安全模式下时,此功能不能生效。

除了关闭安全模式或改变php.ini中的时间限制,没有别的办法。

Note:

set_time_limit()函数和配置指令max_execution_time只影响脚本本身执行的时间。

任何发生在诸如使用system()的系统调用,流操作,数据库操作等的脚本执行的最大时间不包括其中,当该脚本已运行。

在测量时间是实值的Windows中,情况就不是如此了。

·sys_get_temp_dir -Returnsdirectorypathusedfortemporaryfiles

sys_get_temp_dir

(PHP5>=5.2.1)

sys_get_temp_dir — Returnsdirectorypathusedfortemporaryfiles

说明

string sys_get_temp_dir ( void )

ReturnsthepathofthedirectoryPHPstorestemporaryfilesinbydefault.

返回值

Returnsthepathofthetemporarydirectory.

范例

Example#1 sys_get_temp_dir() example

php

// Create a temporary file in the temporary 

// files directory using sys_get_temp_dir()

$temp_file = tempnam(sys_get_temp_dir(), 'Tux');

echo $temp_file;

?

>

以上例程的输出类似于:

C:

WindowsTempTuxA318.tmp

·version_compare -Comparestwo"PHP-standardized"versionnumberstrings

version_compare

(PHP4>=4.1.0,PHP5)

version_compare — Comparestwo"PHP-standardized"versionnumberstrings

说明

mixed version_compare ( string $version1 , string $version2 [, string $operator])

version_compare() comparestwo"PHP-standardized"versionnumberstrings.ThisisusefulifyouwouldliketowriteprogramsworkingonlyonsomeversionsofPHP.

Thefunctionfirstreplaces _, - and + withadot . intheversionstringsandalsoinsertsdots . beforeandafteranynonnumbersothatforexample'4.3.2RC1'becomes'4.3.2.RC.1'.Thenitsplitstheresultslikeifyouwereusingexplode('.',$ver).Thenitcomparesthepartsstartingfromlefttoright.Ifapartcontainsspecialversionstringsthesearehandledinthefollowingorder:

 anystringnotfoundinthislist < dev < alpha = a < beta = b < RC = rc < # < pl = p.Thiswaynotonlyversionswithdifferentlevelslike'4.1'and'4.1.2'canbecomparedbutalsoanyPHPspecificversioncontainingdevelopmentstate.

参数

version1

Firstversionnumber.

version2

Secondversionnumber.

operator

Ifyouspecifythethirdoptional operator argument,youcantestforaparticularrelationship.Thepossibleoperatorsare:

 <, lt, <=, le, >, gt,>=, ge, ==, =, eq, !

=, <>, ne respectively.

Thisparameteriscase-sensitive,sovaluesshouldbelowercase.

返回值

Bydefault, version_compare() returns -1 ifthefirstversionislowerthanthesecond, 0 iftheyareequal,and 1 ifthesecondislower.

Whenusingtheoptional operator argument,thefunctionwillreturn TRUE iftherelationshipistheonespecifiedbytheoperator, FALSE otherwise.

范例

Theexamplesbelowusethe PHP_VERSION constant,becauseitcontainsthevalueofthePHPversionthatisexecutingthecode.

Example#1 version_compare() examples

php

if (version_compare(PHP_VERSION, '6.0.0') >= 0) {

    echo 'I am at least PHP version 6.0.0, my version:

 ' . PHP_VERSION . "";

}

if (version_compare(PHP_VERSION, '5.3.0') >= 0) {

    echo 'I am at least PHP version 5.3.0, my version:

 ' . PHP_VERSION . "";

}

if (version_compare(PHP_VERSION, '5.0.0', '>=')) {

    echo 'I am using PHP 5, my version:

 ' . PHP_VERSION . "";

}

if (version_compare(PHP_VERSION, '5.0.0', '<')) {

    echo 'I am using PHP 4, my version:

 ' . PHP_VERSION . "";

}

?

>

注释

Note:

The PHP_VERSION constantholdscurrentPHPversion.

Note:

Notethatpre-releaseversions,suchas5.3.0-dev,areconsideredlowerthantheirfinalreleasecounterparts(like5.3.0).

·zend_logo_guid -GetstheZendguid

zend_logo_guid

(PHP4,PHP5)

zend_logo_guid — GetstheZendguid

说明

string zend_logo_guid ( void )

ThisfunctionreturnstheIDwhichcanbeusedtodisplaytheZendlogousingthebuilt-inimage.

返回值

Returns PHPE9568F35-D428-11d2-A769-00AA001ACF42.

范例

Example#1 zend_logo_guid() example

php

echo '

     '?

=' . zend_logo_guid() . '" alt="Zend Logo !

" />';

?

>

·zend_thread_id -Returnsauniqueidentifierforthecurrentthread

zend_thread_id

(PHP5)

zend_thread_id — Returnsauniqueidentifierforthecurrentthread

说明

int zend_thread_id ( void )

Thisfunctionreturnsauniqueidentifierforthecurrentthread.

返回值

Returnsthethreadidasaninteger.

范例

Example#1 zend_thread_id() example

php

$thread_id = zend_thread_id();

echo 'Current thread id is:

 ' . $thread_id;

?

>

以上例程的输出类似于:

Currentthreadidis:

7864

注释

Note:

ThisfunctionisonlyavailableifPHPhasbeenbuiltwithZTS(ZendThreadSafety)supportanddebugmode(--enable-debug).

·zend_version -GetstheversionofthecurrentZendengine

zend_version

(PHP4,PHP5)

zend_version — GetstheversionofthecurrentZendengine

说明

string zend_version ( void )

ReturnsastringcontainingtheversionofthecurrentlyrunningZendEngine.

返回值

ReturnstheZendEngineversionnumber,asastring.

范例

Example#1 zend_version() example

php

echo "Zend engine version:

 " . zend_version();

?

>

以上例程的输出类似于:

Zendengineversion:

2.2.0

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 考试认证 > 其它考试

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2