如题所述
转èªï¼http://www.nginx.cn/2677.html
FIGç»ç»å¨å¶å®è·PHPç¸å ³è§èï¼ç®ç§°PSRï¼PSRæ¨å¨éè¿è®¨è®ºæ们代ç 项ç®çå ±åç¹ä»¥æ¾åºä¸ä¸ªåä½ç¼ç¨çæ¹æ³ã
ä»ä¹æ¯psr0强è°èªå¨å è½½çæ¹å¼
ä¸ææè¿°äºè¥è¦ä½¿ç¨ä¸ä¸ªéç¨çèªå¨å è½½å¨(autoloader)ï¼ä½ æéè¦éµå®çè§èï¼
è§è
ä¸ä¸ªå®å ¨æ åçå½å空é´(namespace)åç±»(class)çç»ææ¯è¿æ ·çï¼\*
æ¯ä¸ªå½å空é´(namespace)é½å¿ é¡»æä¸ä¸ªé¡¶çº§ç空é´å(namespace)("ç»ç»å(Vendor Name)")ã
æ¯ä¸ªå½å空é´(namespace)ä¸å¯ä»¥æ ¹æ®éè¦ä½¿ç¨ä»»ææ°éçåå½å空é´(sub-namespace)ã
ä»æ件系ç»ä¸å è½½æºæ件æ¶ï¼ç©ºé´å(namespace)ä¸çåé符å°è¢«è½¬æ¢ä¸º DIRECTORY_SEPARATORã
ç±»å(class name)ä¸çæ¯ä¸ªä¸å线_é½å°è¢«è½¬æ¢ä¸ºä¸ä¸ªDIRECTORY_SEPARATORãä¸å线_å¨ç©ºé´å(namespace)ä¸æ²¡æä»ä¹ç¹æ®çæä¹ã
å®å ¨æ åçå½å空é´(namespace)åç±»(class)ä»æ件系ç»å è½½æºæ件æ¶å°ä¼å ä¸.phpåç¼ã
ç»ç»å(vendor name)ï¼ç©ºé´å(namespace)ï¼ç±»å(class name)é½ç±å¤§å°ååæ¯ç»åèæã
示ä¾
\Doctrine\Common\IsolatedClassLoader => /path/to/project/lib/vendor/Doctrine/Common/IsolatedClassLoader.php
\Symfony\Core\Request => /path/to/project/lib/vendor/Symfony/Core/Request.php
\Zend\Acl => /path/to/project/lib/vendor/Zend/Acl.php
\Zend\Mail\Message => /path/to/project/lib/vendor/Zend/Mail/Message.php
空é´å(namespace)åç±»å(class name)ä¸çä¸å线
\namespace\package\Class_Name => /path/to/project/lib/vendor/namespace/package/Class/Name.php
\namespace\package_name\Class_Name => /path/to/project/lib/vendor/namespace/package_name/Class/Name.php
以ä¸æ¯æ们为å®ç°éç¨çèªå¨å è½½èå¶å®çæä½æ åãä½ å¯ä»¥å©ç¨è½å¤èªå¨å è½½PHP 5.3ç±»çSplClassLoaderæ¥æµè¯ä½ ç代ç æ¯å¦ç¬¦åè¿äºæ åã
å®ä¾
ä¸é¢æ¯ä¸ä¸ªææ ·å©ç¨ä¸è¿°æ åæ¥å®ç°èªå¨å è½½ç示ä¾å½æ°ã
<?php
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
require $fileName;
}
SplClassLoaderå®ç°
ä¸é¢çgistæ¯ä¸ä¸ªæç §ä¸é¢å»ºè®®çæ åæ¥èªå¨å 载类çSplClassLoaderå®ä¾ãè¿æ¯ä¾æ®è¿äºæ åæ¥å è½½PHP 5.3ç±»çæ¨èæ¹æ¡ã
ä»ä¹æ¯psr1ï¼å®ä¹åºæ¬ä»£ç è§è
æ¬èæ们å°ä¼è®¨è®ºä¸äºåºæ¬ç代ç è§èé®é¢ï¼ä»¥æ¤ä½ä¸ºå°æ¥è®¨è®ºæ´é«çº§å«ç代ç å享åææ¯äºç¨çåºç¡ã
RFC 2119ä¸çå¿ é¡»(MUST)ï¼ä¸å¯(MUST NOT)ï¼å»ºè®®(SHOULD)ï¼ä¸å»ºè®®(SHOULD NOT)ï¼å¯ä»¥/å¯è½(MAY)çå ³é®è¯å°å¨æ¬èç¨æ¥åä¸äºè§£éæ§çæè¿°ã
1. æ¦è¿°
æºæä»¶å¿ é¡»åªä½¿ç¨ å è¿ä¸¤ç§æ ç¾ã
æºæ件ä¸php代ç çç¼ç æ ¼å¼å¿ é¡»åªä½¿ç¨ä¸å¸¦åè顺åºæ è®°(BOM)çUTF-8ã
ä¸ä¸ªæºæ件建议åªç¨æ¥å声æï¼ç±»(class)ï¼å½æ°(function)ï¼å¸¸é(constant)çï¼æè åªç¨æ¥åä¸äºå¼èµ·å¯ä½ç¨çæä½ï¼ä¾å¦ï¼è¾åºä¿¡æ¯ï¼ä¿®æ¹.inié ç½®çï¼,ä½ä¸å»ºè®®åæ¶åè¿ä¸¤ä»¶äºã
å½å空é´(namespace)åç±»(class) å¿ é¡»éµå®PSR-0æ åã
ç±»å(class name) å¿ é¡»ä½¿ç¨éªé©¼å¼(StudlyCaps)åæ³ (è¯è 注ï¼é©¼å³°å¼(cameCase)çä¸ç§åç§ï¼åæå°ç´æ¥ç¨StudlyCaps表示)ã
ç±»(class)ä¸ç常éå¿ é¡»åªç±å¤§ååæ¯åä¸å线(_)ç»æã
æ¹æ³å(method name) å¿ é¡»ä½¿ç¨é©¼å³°å¼(cameCase)åæ³(è¯è 注ï¼åæå°ç´æ¥ç¨camelCase表示)ã
2. æ件
2.1. PHPæ ç¾
PHP代ç å¿ é¡»åªä½¿ç¨é¿æ ç¾()æè çè¾åºå¼æ ç¾(<?= ?>)ï¼èä¸å¯ä½¿ç¨å ¶ä»æ ç¾ã
2.2. å符ç¼ç
PHP代ç çç¼ç æ ¼å¼å¿ é¡»åªä½¿ç¨ä¸å¸¦åè顺åºæ è®°(BOM)çUTF-8ã
2.3. å¯ä½ç¨
ä¸ä¸ªæºæ件建议åªç¨æ¥å声æï¼ç±»(class)ï¼å½æ°(function)ï¼å¸¸é(constant)çï¼æè åªç¨æ¥åä¸äºå¼èµ·å¯ä½ç¨çæä½ï¼ä¾å¦ï¼è¾åºä¿¡æ¯ï¼ä¿®æ¹.inié ç½®çï¼,ä½ä¸å»ºè®®åæ¶åè¿ä¸¤ä»¶äºã
çè¯å¯ä½ç¨(side effects)çæææ¯ å¨å å«æä»¶æ¶ ææ§è¡çé»è¾ä¸æ声æçç±»(class)ï¼å½æ°(function)ï¼å¸¸é(constant)ç没æç´æ¥çå ³ç³»ã
å¯ä½ç¨(side effects)å å«ä½ä¸å±éäºï¼äº§çè¾åºï¼æ¾å¼å°ä½¿ç¨requireæincludeï¼è¿æ¥å¤é¨æå¡ï¼ä¿®æ¹inié ç½®ï¼è§¦åé误æå¼å¸¸ï¼ä¿®æ¹å ¨å±æè éæåéï¼è¯»åæä¿®æ¹æ件çç
ä¸é¢æ¯ä¸ä¸ªæ¢å å«å£°æåæå¯ä½ç¨ç示ä¾æ件ï¼å³åºé¿å çä¾åï¼
<?php
// å¯ä½ç¨ï¼ä¿®æ¹äºinié ç½®
ini_set('error_reporting', E_ALL);
// å¯ä½ç¨ï¼è½½å ¥äºæ件
include "file.php";
// å¯ä½ç¨ï¼äº§çäºè¾åº
echo "<html>\n";
// 声æ
function foo()
{
// å½æ°ä½
}
ä¸é¢æ¯ä¸ä¸ªä» å å«å£°æç示ä¾æ件ï¼å³åºæå¡çä¾åï¼
<?php
// 声æ
function foo()
{
// å½æ°ä½
}
// æ¡ä»¶å¼å£°æä¸ç®åæ¯å¯ä½ç¨
if (! function_exists('bar')) {
function bar()
{
// å½æ°ä½
}
}
3. 空é´å(namespace)åç±»å(class name)
å½å空é´(namespace)åç±»(class)å¿ é¡»éµå® PSR-0.
è¿æå³çä¸ä¸ªæºæ件ä¸åªè½æä¸ä¸ªç±»(class)ï¼å¹¶ä¸æ¯ä¸ªç±»(class)è³å°è¦æä¸çº§ç©ºé´åï¼namespaceï¼ï¼å³ä¸ä¸ªé¡¶çº§çç»ç»å(vendor name)ã
ç±»å(class name) å¿ é¡»ä½¿ç¨StudlyCapsåæ³ã
PHP5.3ä¹åç代ç å¿ é¡»ä½¿ç¨æ£å¼çå½å空é´(namespace) ä¾åï¼
<?php
// PHP 5.3 åä¹å:
namespace Vendor\Model;
class Foo
{
}
PHP5.2.xä¹åç代ç 建议ç¨ä¼ªå½å空é´Vendor_ä½ä¸ºç±»å(class name)çåç¼
<?php
// PHP 5.2.x åä¹å:
class Vendor_Model_Foo
{
}
4. ç±»ç常éãå±æ§åæ¹æ³
æ¯è¯ç±»(class)æææçç±»(class)ï¼æ¥å£(interface)åç¹æ§(trait)
4.1. 常é
类常éå¿ é¡»åªç±å¤§ååæ¯åä¸å线(_)ç»æã ä¾åï¼
<?php
namespace Vendor\Model;
class Foo
{
const VERSION = '1.0';
const DATE_APPROVED = '2012-06-01';
}
4.2. å±æ§
æ¬æåä¸æ æä¸å¯¹$StulyCapsï¼$camelCaseæè $unser_scoreä¸çæä¸ç§é£æ ¼ä½ç¹å«æ¨èï¼å®å ¨ç±è¯»è ä¾æ®ä¸ªäººå好å³å®å±æ§åçå½åé£æ ¼ã
ä½æ¯ä¸ç®¡ä½ å¦ä½å®ä¹å±æ§åï¼å»ºè®®å¨ä¸ä¸ªåççèå´å ä¿æä¸è´ãè¿ä¸ªèå´å¯è½æ¯ç»ç»(vendor)级å«çï¼å (package)级å«çï¼ç±»(class)级å«çï¼æè æ¹æ³(method)级å«çã
4.3. æ¹æ³
æ¹æ³ååå¿ é¡»ä½¿ç¨camelCase()é£æ ¼æ¥å£°æã
ä»ä¹æ¯PSR2å®ä¹ä»£ç é£æ ¼
代ç é£æ ¼æå
æ¬æåæ¯åºç¡ä»£ç è§è(PSR-1)ç继æ¿åæ©å±ã
为äºå°½å¯è½çæåé è¯»å ¶ä»äººä»£ç æ¶çæçï¼ä¸é¢ä¾ä¸¾äºä¸ç³»åçéç¨è§åï¼ç¹å«æ¯æå ³äºPHP代ç é£æ ¼çã
å个æå项ç®é´çå ±æ§ç»æäºè¿ç»ä»£ç è§èãå½å¼åè 们å¨å¤ä¸ªé¡¹ç®ä¸åä½æ¶ï¼æ¬æåå°ä¼æ为ææè¿äºé¡¹ç®ä¸å ±ç¨çä¸ç»ä»£ç è§èã å æ¤ï¼æ¬æåççå¤ä¸å¨äºè¿äºè§åæ¬èº«ï¼èå¨äºå¨ææ项ç®ä¸å ±ç¨è¿äºè§åã
RFC 2119ä¸çå¿ é¡»(MUST)ï¼ä¸å¯(MUST NOT)ï¼å»ºè®®(SHOULD)ï¼ä¸å»ºè®®(SHOULD NOT)ï¼å¯ä»¥/å¯è½(MAY)çå ³é®è¯å°å¨æ¬èç¨æ¥åä¸äºè§£éæ§çæè¿°ã
FIGç»ç»å¨å¶å®è·PHPç¸å ³è§èï¼ç®ç§°PSRï¼PSRæ¨å¨éè¿è®¨è®ºæ们代ç 项ç®çå ±åç¹ä»¥æ¾åºä¸ä¸ªåä½ç¼ç¨çæ¹æ³ã
ä»ä¹æ¯psr0强è°èªå¨å è½½çæ¹å¼
ä¸ææè¿°äºè¥è¦ä½¿ç¨ä¸ä¸ªéç¨çèªå¨å è½½å¨(autoloader)ï¼ä½ æéè¦éµå®çè§èï¼
è§è
ä¸ä¸ªå®å ¨æ åçå½å空é´(namespace)åç±»(class)çç»ææ¯è¿æ ·çï¼\*
æ¯ä¸ªå½å空é´(namespace)é½å¿ é¡»æä¸ä¸ªé¡¶çº§ç空é´å(namespace)("ç»ç»å(Vendor Name)")ã
æ¯ä¸ªå½å空é´(namespace)ä¸å¯ä»¥æ ¹æ®éè¦ä½¿ç¨ä»»ææ°éçåå½å空é´(sub-namespace)ã
ä»æ件系ç»ä¸å è½½æºæ件æ¶ï¼ç©ºé´å(namespace)ä¸çåé符å°è¢«è½¬æ¢ä¸º DIRECTORY_SEPARATORã
ç±»å(class name)ä¸çæ¯ä¸ªä¸å线_é½å°è¢«è½¬æ¢ä¸ºä¸ä¸ªDIRECTORY_SEPARATORãä¸å线_å¨ç©ºé´å(namespace)ä¸æ²¡æä»ä¹ç¹æ®çæä¹ã
å®å ¨æ åçå½å空é´(namespace)åç±»(class)ä»æ件系ç»å è½½æºæ件æ¶å°ä¼å ä¸.phpåç¼ã
ç»ç»å(vendor name)ï¼ç©ºé´å(namespace)ï¼ç±»å(class name)é½ç±å¤§å°ååæ¯ç»åèæã
示ä¾
\Doctrine\Common\IsolatedClassLoader => /path/to/project/lib/vendor/Doctrine/Common/IsolatedClassLoader.php
\Symfony\Core\Request => /path/to/project/lib/vendor/Symfony/Core/Request.php
\Zend\Acl => /path/to/project/lib/vendor/Zend/Acl.php
\Zend\Mail\Message => /path/to/project/lib/vendor/Zend/Mail/Message.php
空é´å(namespace)åç±»å(class name)ä¸çä¸å线
\namespace\package\Class_Name => /path/to/project/lib/vendor/namespace/package/Class/Name.php
\namespace\package_name\Class_Name => /path/to/project/lib/vendor/namespace/package_name/Class/Name.php
以ä¸æ¯æ们为å®ç°éç¨çèªå¨å è½½èå¶å®çæä½æ åãä½ å¯ä»¥å©ç¨è½å¤èªå¨å è½½PHP 5.3ç±»çSplClassLoaderæ¥æµè¯ä½ ç代ç æ¯å¦ç¬¦åè¿äºæ åã
å®ä¾
ä¸é¢æ¯ä¸ä¸ªææ ·å©ç¨ä¸è¿°æ åæ¥å®ç°èªå¨å è½½ç示ä¾å½æ°ã
<?php
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
require $fileName;
}
SplClassLoaderå®ç°
ä¸é¢çgistæ¯ä¸ä¸ªæç §ä¸é¢å»ºè®®çæ åæ¥èªå¨å 载类çSplClassLoaderå®ä¾ãè¿æ¯ä¾æ®è¿äºæ åæ¥å è½½PHP 5.3ç±»çæ¨èæ¹æ¡ã
ä»ä¹æ¯psr1ï¼å®ä¹åºæ¬ä»£ç è§è
æ¬èæ们å°ä¼è®¨è®ºä¸äºåºæ¬ç代ç è§èé®é¢ï¼ä»¥æ¤ä½ä¸ºå°æ¥è®¨è®ºæ´é«çº§å«ç代ç å享åææ¯äºç¨çåºç¡ã
RFC 2119ä¸çå¿ é¡»(MUST)ï¼ä¸å¯(MUST NOT)ï¼å»ºè®®(SHOULD)ï¼ä¸å»ºè®®(SHOULD NOT)ï¼å¯ä»¥/å¯è½(MAY)çå ³é®è¯å°å¨æ¬èç¨æ¥åä¸äºè§£éæ§çæè¿°ã
1. æ¦è¿°
æºæä»¶å¿ é¡»åªä½¿ç¨ å è¿ä¸¤ç§æ ç¾ã
æºæ件ä¸php代ç çç¼ç æ ¼å¼å¿ é¡»åªä½¿ç¨ä¸å¸¦åè顺åºæ è®°(BOM)çUTF-8ã
ä¸ä¸ªæºæ件建议åªç¨æ¥å声æï¼ç±»(class)ï¼å½æ°(function)ï¼å¸¸é(constant)çï¼æè åªç¨æ¥åä¸äºå¼èµ·å¯ä½ç¨çæä½ï¼ä¾å¦ï¼è¾åºä¿¡æ¯ï¼ä¿®æ¹.inié ç½®çï¼,ä½ä¸å»ºè®®åæ¶åè¿ä¸¤ä»¶äºã
å½å空é´(namespace)åç±»(class) å¿ é¡»éµå®PSR-0æ åã
ç±»å(class name) å¿ é¡»ä½¿ç¨éªé©¼å¼(StudlyCaps)åæ³ (è¯è 注ï¼é©¼å³°å¼(cameCase)çä¸ç§åç§ï¼åæå°ç´æ¥ç¨StudlyCaps表示)ã
ç±»(class)ä¸ç常éå¿ é¡»åªç±å¤§ååæ¯åä¸å线(_)ç»æã
æ¹æ³å(method name) å¿ é¡»ä½¿ç¨é©¼å³°å¼(cameCase)åæ³(è¯è 注ï¼åæå°ç´æ¥ç¨camelCase表示)ã
2. æ件
2.1. PHPæ ç¾
PHP代ç å¿ é¡»åªä½¿ç¨é¿æ ç¾()æè çè¾åºå¼æ ç¾(<?= ?>)ï¼èä¸å¯ä½¿ç¨å ¶ä»æ ç¾ã
2.2. å符ç¼ç
PHP代ç çç¼ç æ ¼å¼å¿ é¡»åªä½¿ç¨ä¸å¸¦åè顺åºæ è®°(BOM)çUTF-8ã
2.3. å¯ä½ç¨
ä¸ä¸ªæºæ件建议åªç¨æ¥å声æï¼ç±»(class)ï¼å½æ°(function)ï¼å¸¸é(constant)çï¼æè åªç¨æ¥åä¸äºå¼èµ·å¯ä½ç¨çæä½ï¼ä¾å¦ï¼è¾åºä¿¡æ¯ï¼ä¿®æ¹.inié ç½®çï¼,ä½ä¸å»ºè®®åæ¶åè¿ä¸¤ä»¶äºã
çè¯å¯ä½ç¨(side effects)çæææ¯ å¨å å«æä»¶æ¶ ææ§è¡çé»è¾ä¸æ声æçç±»(class)ï¼å½æ°(function)ï¼å¸¸é(constant)ç没æç´æ¥çå ³ç³»ã
å¯ä½ç¨(side effects)å å«ä½ä¸å±éäºï¼äº§çè¾åºï¼æ¾å¼å°ä½¿ç¨requireæincludeï¼è¿æ¥å¤é¨æå¡ï¼ä¿®æ¹inié ç½®ï¼è§¦åé误æå¼å¸¸ï¼ä¿®æ¹å ¨å±æè éæåéï¼è¯»åæä¿®æ¹æ件çç
ä¸é¢æ¯ä¸ä¸ªæ¢å å«å£°æåæå¯ä½ç¨ç示ä¾æ件ï¼å³åºé¿å çä¾åï¼
<?php
// å¯ä½ç¨ï¼ä¿®æ¹äºinié ç½®
ini_set('error_reporting', E_ALL);
// å¯ä½ç¨ï¼è½½å ¥äºæ件
include "file.php";
// å¯ä½ç¨ï¼äº§çäºè¾åº
echo "<html>\n";
// 声æ
function foo()
{
// å½æ°ä½
}
ä¸é¢æ¯ä¸ä¸ªä» å å«å£°æç示ä¾æ件ï¼å³åºæå¡çä¾åï¼
<?php
// 声æ
function foo()
{
// å½æ°ä½
}
// æ¡ä»¶å¼å£°æä¸ç®åæ¯å¯ä½ç¨
if (! function_exists('bar')) {
function bar()
{
// å½æ°ä½
}
}
3. 空é´å(namespace)åç±»å(class name)
å½å空é´(namespace)åç±»(class)å¿ é¡»éµå® PSR-0.
è¿æå³çä¸ä¸ªæºæ件ä¸åªè½æä¸ä¸ªç±»(class)ï¼å¹¶ä¸æ¯ä¸ªç±»(class)è³å°è¦æä¸çº§ç©ºé´åï¼namespaceï¼ï¼å³ä¸ä¸ªé¡¶çº§çç»ç»å(vendor name)ã
ç±»å(class name) å¿ é¡»ä½¿ç¨StudlyCapsåæ³ã
PHP5.3ä¹åç代ç å¿ é¡»ä½¿ç¨æ£å¼çå½å空é´(namespace) ä¾åï¼
<?php
// PHP 5.3 åä¹å:
namespace Vendor\Model;
class Foo
{
}
PHP5.2.xä¹åç代ç 建议ç¨ä¼ªå½å空é´Vendor_ä½ä¸ºç±»å(class name)çåç¼
<?php
// PHP 5.2.x åä¹å:
class Vendor_Model_Foo
{
}
4. ç±»ç常éãå±æ§åæ¹æ³
æ¯è¯ç±»(class)æææçç±»(class)ï¼æ¥å£(interface)åç¹æ§(trait)
4.1. 常é
类常éå¿ é¡»åªç±å¤§ååæ¯åä¸å线(_)ç»æã ä¾åï¼
<?php
namespace Vendor\Model;
class Foo
{
const VERSION = '1.0';
const DATE_APPROVED = '2012-06-01';
}
4.2. å±æ§
æ¬æåä¸æ æä¸å¯¹$StulyCapsï¼$camelCaseæè $unser_scoreä¸çæä¸ç§é£æ ¼ä½ç¹å«æ¨èï¼å®å ¨ç±è¯»è ä¾æ®ä¸ªäººå好å³å®å±æ§åçå½åé£æ ¼ã
ä½æ¯ä¸ç®¡ä½ å¦ä½å®ä¹å±æ§åï¼å»ºè®®å¨ä¸ä¸ªåççèå´å ä¿æä¸è´ãè¿ä¸ªèå´å¯è½æ¯ç»ç»(vendor)级å«çï¼å (package)级å«çï¼ç±»(class)级å«çï¼æè æ¹æ³(method)级å«çã
4.3. æ¹æ³
æ¹æ³ååå¿ é¡»ä½¿ç¨camelCase()é£æ ¼æ¥å£°æã
ä»ä¹æ¯PSR2å®ä¹ä»£ç é£æ ¼
代ç é£æ ¼æå
æ¬æåæ¯åºç¡ä»£ç è§è(PSR-1)ç继æ¿åæ©å±ã
为äºå°½å¯è½çæåé è¯»å ¶ä»äººä»£ç æ¶çæçï¼ä¸é¢ä¾ä¸¾äºä¸ç³»åçéç¨è§åï¼ç¹å«æ¯æå ³äºPHP代ç é£æ ¼çã
å个æå项ç®é´çå ±æ§ç»æäºè¿ç»ä»£ç è§èãå½å¼åè 们å¨å¤ä¸ªé¡¹ç®ä¸åä½æ¶ï¼æ¬æåå°ä¼æ为ææè¿äºé¡¹ç®ä¸å ±ç¨çä¸ç»ä»£ç è§èã å æ¤ï¼æ¬æåççå¤ä¸å¨äºè¿äºè§åæ¬èº«ï¼èå¨äºå¨ææ项ç®ä¸å ±ç¨è¿äºè§åã
RFC 2119ä¸çå¿ é¡»(MUST)ï¼ä¸å¯(MUST NOT)ï¼å»ºè®®(SHOULD)ï¼ä¸å»ºè®®(SHOULD NOT)ï¼å¯ä»¥/å¯è½(MAY)çå ³é®è¯å°å¨æ¬èç¨æ¥åä¸äºè§£éæ§çæè¿°ã
温馨提示:答案为网友推荐,仅供参考