1、PHP函数库分类三十四PHP函数库分类三十四10.PHP选项/信息函数列表6 phpcredits- Prints out the credits for PHPphpcredits(PHP 4, PHP 5)phpcreditsPrints out the credits for PHP说明boolphpcredits(int$flag= CREDITS_ALL )This function prints out the credits listing the PHP developers, modules, etc. It generates the appropriate HTML co
2、des to insert the information in a page.参数flagTo generate a custom credits page, you may want to use theflagparameter.Pre-definedphpcredits()flagsnamedescriptionCREDITS_ALLAll the credits, equivalent to using:CREDITS_DOCS+CREDITS_GENERAL+CREDITS_GROUP+CREDITS_MODULES+CREDITS_FULLPAGE. It generates a
3、 complete stand-alone HTML page with the appropriate tags.CREDITS_DOCSThe credits for the documentation teamCREDITS_FULLPAGEUsually used in combination with the other flags. Indicates that a complete stand-alone HTML page needs to be printed including the information indicated by the other flags.CRE
4、DITS_GENERALGeneral credits: Language design and concept, PHP authors and SAPI module.CREDITS_GROUPA list of the core developersCREDITS_MODULESA list of the extension modules for PHP, and their authorsCREDITS_SAPIA list of the server API modules for PHP, and their authors返回值成功时返回TRUE, 或者在失败时返回FALSE.
5、范例Example #1 Prints the general creditsExample #2 Prints the core developers and the documentation groupExample #3 Printing all the creditsMycreditspage phpversion- Gets the current PHP versionphpversion(PHP 4, PHP 5)phpversionGets the current PHP version说明stringphpversion(string$extension )Returns
6、a string containing the version of the currently running PHP parser or extension.参数extensionAn optional extension name.返回值If the optionalextensionparameter is specified,phpversion()returns the version of that extension, orFALSEif there is no version information associated or the extension isnt enabl
7、ed.范例Example #1phpversion()exampleExample #2PHP_VERSION_IDexample and usage?php/PHP_VERSION_IDisavailableasofPHP5.2.7,ifour/versionislowerthanthat,thenemulateitif(!defined(PHP_VERSION_ID)$version=explode(.,PHP_VERSION);define(PHP_VERSION_ID,($version0*10000+$version1*100+$version2);/PHP_VERSION_IDis
8、definedasanumber,wherethehigherthenumber/is,theneweraPHPversionisused.Itsdefinedasusedintheabove/expression:/$version_id=$major_version*10000+$minor_version*100+$release_version;/NowwithPHP_VERSION_IDwecancheckforfeaturesthisPHPversion/mayhave,thisdoesntrequiretouseversion_compare()everytime/youchec
9、kifthecurrentPHPversionmaynotsupportafeature./Forexample,wemayheredefinethePHP_VERSION_*constantsthats/notavailableinversionspriorto5.2.7if(PHP_VERSION_ID注释Note:This information is also available in the predefined constantPHP_VERSION. More versioning information is available using thePHP_VERSION_*co
10、nstants. php_ini_loaded_file- Retrieve a path to the loaded php.ini filephp_ini_loaded_file(PHP 5 = 5.2.4)php_ini_loaded_fileRetrieve a path to the loaded php.ini file说明stringphp_ini_loaded_file(void)Check if aphp.inifile is loaded, and retrieve its path.参数此函数没有参数。返回值The loadedphp.inipath, orFALSEif
11、 one is not loaded.范例Example #1php_ini_loaded_file()example以上例程的输出类似于:Loaded php.ini: /usr/local/php/php.ini php_ini_scanned_files- Return a list of .ini files parsed from the additional ini dirphp_ini_scanned_files(PHP 4 = 4.3.0, PHP 5)php_ini_scanned_filesReturn a list of .ini files parsed from th
12、e additional ini dir说明stringphp_ini_scanned_files(void)php_ini_scanned_files()returns a comma-separated list of configuration files parsed afterphp.ini. These files are found in a directory defined by the-with-config-file-scan-diroption which is set during compilation.The returned configuration file
13、s also include the path as declared in the-with-config-file-scan-diroption.返回值Returns a comma-separated string of .ini files on success. Each comma is followed by a newline. If the directive-with-config-file-scan-dirwasnt set,FALSEis returned. If it was set and the directory was empty, an empty stri
14、ng is returned. If a file is unrecognizable, the file will still make it into the returned string but a PHP error will also result. This PHP error will be seen both at compile time and while usingphp_ini_scanned_files().范例Example #1 A simple example to list the returned ini files0)$files=explode(,$f
15、ilelist);foreach($filesas$file)echo.trim($file). ;? php_logo_guid- Gets the logo guidphp_logo_guid(PHP 4, PHP 5)php_logo_guidGets the logo guid说明stringphp_logo_guid(void)This function returns the ID which can be used to display the PHP logo using the built-in image. Logo is displayed only if expose_
16、php is On.返回值ReturnsPHPE9568F34-D428-11d2-A769-00AA001ACF42.范例Example #1php_logo_guid()example?phpecho;? php_sapi_name- Returns the type of interface between web server and PHPphp_sapi_name(PHP 4 = 4.0.1, PHP 5)php_sapi_nameReturns the type of interface between web server and PHP说明stringphp_sapi_nam
17、e(void)Returns a lowercase string that describes the type of interface (the Server API, SAPI) that PHP is using. For example, in CLI PHP this string will be cli whereas with Apache it may have several different values depending on the exact SAPI used. Possible values are listed below.返回值Returns the
18、interface type, as a lowercase string.Although not exhaustive, the possible return values includeaolserver,apache,apache2filter,apache2handler,caudium,cgi(until PHP 5.3),cgi-fcgi,cli,continuity,embed,isapi,litespeed,milter,nsapi,phttpd,pi3web,roxen,thttpd,tux, andwebjames.范例Example #1php_sapi_name()
19、exampleThis example checks for the substringcgibecause it may also becgi-fcgi.注释Note:An alternative approachThe PHP constantPHP_SAPIhas the same value asphp_sapi_name().TipA potential gotchaThe definedSAPImay not be obvious, because for example instead ofapacheit may be defined asapache2handlerorapa
20、che2filter. php_uname- Returns information about the operating system PHP is running onphp_uname(PHP 4 = 4.0.2, PHP 5)php_unameReturns information about the operating system PHP is running on说明stringphp_uname(string$mode= a )php_uname()returns a description of the operating system PHP is running on.
21、 This is the same string you see at the very top of thephpinfo()output. For the name of just the operating system, consider using thePHP_OSconstant, but keep in mind this constant will contain the operating system PHP wasbuilton.On some older UNIX platforms, it may not be able to determine the curre
22、nt OS information in which case it will revert to displaying the OS PHP was built on. This will only happen if your uname() library call either doesnt exist or doesnt work.参数modemodeis a single character that defines what information is returned: a: This is the default. Contains all modes in the seq
23、uences n r v m. s: Operating system name. eg.FreeBSD. n: Host name. eg. r: Release name. eg.5.1.2-RELEASE. v: Version information. Varies a lot between operating systems. m: Machine type. eg.i386.返回值Returns the description, as a string.范例Example #1 Somephp_uname()examplesThere are also some relatedP
24、redefined PHP constantsthat may come in handy, for example:Example #2 A few OS related constant examples putenv- Sets the value of an environment variableputenv(PHP 4, PHP 5)putenvSets the value of an environment variable说明boolputenv(string$setting)Addssettingto the server environment. The environment variable will only exist for the duration of the current request. At the end of the request the environment is rest
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1