?? ??? ?? Yii ? ??????? ?? ?? ??? ????? ?? ?? ?? ??? ?? ??? ??????? ??? ? ????. ? ?? ???? Yii ????? ?? ?? ????(1) ? ?? ?????? Hello World?? Yii ? ??????? ??? MVC ??? ?????, ?? ? ????? ??? ??? ??(?? Windows ?????? C++ ??? ??)? ?? ???????. , C# ?????? ??)? Windows ???? ?? ???? ?? ASP.Net ?????? PHP Yii Framework ?? ???? ?????? ??? ??? ? ??? ???.
?? CHtml? ?? View(??? ?? ??)? ???? CController? ?? ??? ?? ???? ???? ??? ??????. Windows ???? ???????? ASP.Net? ???? Yii ?? ?? ??(HTML Form)? WinForm? ?????. ?? Asp.Net ???. Control ??? Controller? Windows ???? ?? ???? ?? Asp.Net? ??? ??(Code-Behind) ???? ?????. ???? Asp.Net ? Windows ???? ?? ????? ??? ?? ? ??? ?? UI? ? UI ?? ??? ?? ID? ??? ?? ??? UI ?? ??? ?? ??? ??? ??? ? ??? ????. HTML ??? ??? UI ?? ??? ?? ID? ???? UI ?? ??? ?? ??? ??? ???? PHP ?? ???? ?? Yii ?? ????? ???? ????? ????. ??? Yii ?????? ??? ??? ???? ?? CFormModel? ?????. ??? ?? CFormModel? ?? HTML Form? UI ??? ?? ??? ??? ? ??? ??? ??? ??? ??? Controller?? ???? ? ????. ? Yii ??(??)? ????? "?? ??"? ???? CController ??? ???? actionXXX ???? ??????. actionXXX ?????? CFormModel? ?? HTML ??? UI ?? ??? ???? ? ????. . ?.
?? ?????? ????? Yii? ??? CModel ?? ? ?? ???? ???????. ??? ??? ? ?? ???? ??? ???? ? ?????.
Yii? ?? ??? Active Record?? ? ?? ??? ?????. ? ? ??? ?? ??? CModel?? ?????.
?? ??? CFormModel? ???????. ?? ??? ??? ???? ?? ???? ???? ? ?????. ? ???? ?? ??, ?? ? ?????. ?? ?? ??? ????? ?? ??? ???? ?? ???? ??? ??? ??? ???? ??? ??? ? ????. ??? ??? ????? ??????. ? ???? CFormModel? ???? ?????.
??? ???(AR)? ?? ?? ???? ?? ?????? ???? ????? ? ???? ??? ?????. ? AR ??? CActiveRecord? ???? ?? ?? ?? ??? ? ?????. ??? ???? ?? ?????. ?? ??? AR ??? ??? ?????. AR? ?? ??? ??? Active Record? ??????. ??? ?????? ??? ?? ??? ? ???????.
? ????? ??? ??? ?????? ???? FormModel? ???? ?????.
1. ?? ??? ??
????? ??? ????? ??? ??? ???? ?? LoginForm(protected/models/LoginForm.php) ?? ???? ?????. ??? ??? ??? ???? ???? ??? ??? ???? ?? ??? LoginForm? ?????.
class LoginForm extends CFormModel { public $username; public $password; public $rememberMe=false; }
2. ??? ?? ?? ??
???? ??? ???? ??? ???? ???? ?? ???? ??? ???? ???? ???. ?? ??? ??? ?? ??? ??? ?????? ?????. ?? ?? ??? ???? ?? ??() ???? ??? ??? ?? ??? ?????.
class LoginForm extends CFormModel { public $username; public $password; public $rememberMe=false; private $_identity; public function rules() { return array( array('username, password', 'required'), array('rememberMe', 'boolean'), array('password', 'authenticate'), ); } public function authenticate($attribute,$params) { $this->_identity=new UserIdentity($this->username, $this->password); if(!$this->_identity->authenticate()) $this->addError('password','錯(cuò)誤的用戶名或密碼。'); } }
? ??? ??? ??? ????? ????, ????? ????? ??, RememberMe? ?? ???? ?? ?????.
rules()?? ??? ? ??? ?? ????? ???.
array('AttributeList', 'Validator', 'on'=>'ScenarioList', ...附加選項(xiàng))
??? AttributeList(?? ??)? ???? ?? ?? ?? ??????. ? ??? ? ?? ??? ??? ?????. ??? ???(validator)? ??? ??? ?? ??? ???? ? ??? ???? ?? ???? ??? ?? ??? ?????. - ?? ??? ???? ?? ?? ????? ? ????.
??? ?? ???? ??? ???? ???? ???? ? ??? ????. ??, Validator? ? ??? authenticate? ?? ?? ???? ??? ??? ? ????. ?? ??? ?? ???? ???.
/** * @param string 所要驗(yàn)證的特性的名字 * @param array 驗(yàn)證規(guī)則中指定的選項(xiàng) */ public function ValidatorName($attribute,$params) { ... }
第二,Validator 可以是一個(gè)驗(yàn)證器類的名字,當(dāng)此規(guī)則被應(yīng)用時(shí), 一個(gè)驗(yàn)證器類的實(shí)例將被創(chuàng)建以執(zhí)行實(shí)際驗(yàn)證。規(guī)則中的附加選項(xiàng)用于初始化實(shí)例的屬性值。 驗(yàn)證器類必須繼 承自 CValidator。
第三,Validator 可以是一個(gè)預(yù)定義的驗(yàn)證器類的別名。在上面的例子中, required 名字是 CRequiredValidator 的別名,它用于確保所驗(yàn)證的特性值不為空。 下面是預(yù)定義的驗(yàn)證器別名的完整列表:
boolean: CBooleanValidator 的別名, 確保特性有一個(gè) CBooleanValidator::trueValue 或CBooleanValidator::falseValue 值。
captcha: CCaptchaValidator 的別名,確保特性值等于 CAPTCHA 中顯示的驗(yàn)證碼。
compare: CCompareValidator 的別 名,確保特性等于另一個(gè)特性或常量。
email: CEmailValidator 的別名,確保特性是一個(gè)有效的Email地址。
default: CDefaultValueValidator 的別名,指定特性的默認(rèn)值。
exist: CExistValidator 的別名,確保特性值可以在指定表的列中 可以找到。
file: CFileValidator 的別名,確保特性含有一個(gè)上傳文件的名字。
filter: CFilterValidator 的別名,通 過(guò)一個(gè)過(guò)濾器改變此特性。
in: CRangeValidator 的別名,確保數(shù)據(jù)在一個(gè)預(yù)先指定的值的范圍之內(nèi)。
length: CStringValidator 的別名,確保數(shù)據(jù)的長(zhǎng)度在一個(gè)指定的范圍之內(nèi)。
match: CRegularExpressionValidator 的別名,確保 數(shù)據(jù)可以匹配一個(gè)正則表達(dá)式。
numerical: CNumberValidator 的別名,確保數(shù)據(jù)是一個(gè)有效的數(shù)字。
required: CRequiredValidator 的別名,確保特性不為空。
type: CTypeValidator 的別名,確保特性是指定的數(shù)據(jù)類型。
unique: CUniqueValidator 的別名,確保數(shù)據(jù)在數(shù)據(jù)表的列中是唯一的。
url: CUrlValidator 的別名,確保數(shù)據(jù)是一個(gè)有效的 URL 。
下面我們列出了幾個(gè)只用這些預(yù)定義驗(yàn)證器的示例:
// 用戶名為必填項(xiàng) array('username', 'required'), // 用戶名必須在 3 到 12 個(gè)字符之間 array('username', 'length', 'min'=>3, 'max'=>12), // 在注冊(cè)場(chǎng)景中,密碼password必須和password2一致。 array('password', 'compare', 'compareAttribute'=>'password2', 'on'=>'register'), // 在登錄場(chǎng)景中,密碼必須接受驗(yàn)證。 array('password', 'authenticate', 'on'=>'login'),
3. 安全的特性賦值
在一個(gè)類的實(shí)例被創(chuàng)建后,我 們通常需要用最終用戶提交的數(shù)據(jù)填充它的特性。 這可以通過(guò)如下塊賦值(massive assignment)方式輕松實(shí)現(xiàn):
$model=new LoginForm;
if(isset($_POST['LoginForm']))
$model->attributes=$_POST['LoginForm'];最后的表達(dá)式被稱作 塊賦值(massive assignment) ,它將 $_POST['LoginForm'] 中的每一項(xiàng)復(fù)制到相應(yīng)的模型特性中。這相當(dāng)于如下賦值方法:
foreach($_POST ['LoginForm'] as $name=>$value) { if($name 是一個(gè)安全的特性) $model->$name=$value; }
檢測(cè)特性的安全非常重要,例如,如果我們以為一個(gè)表的主鍵是安全的而暴露了它,那么攻擊者可能就獲得了一個(gè)修 改記錄的主鍵的機(jī)會(huì), 從而篡改未授權(quán)給他的內(nèi)容。
檢測(cè)特性安全的策略在版本 1.0 和 1.1 中是不同的,下面我們將 分別講解:
1.1 中的安全特性
在版本 1.1 中,特性如果出現(xiàn)在相應(yīng)場(chǎng)景的一個(gè)驗(yàn)證規(guī)則中,即被認(rèn)為是安全的 。 例如:
array('username, password', 'required', 'on'=>'login, register'),
array('email', 'required', 'on'=>'register'),如上所示, username 和 password 特性在 login 場(chǎng)景中是必 填項(xiàng)。而 username, password 和 email 特性在register 場(chǎng)景中是必填項(xiàng)。 于是,如果我們?cè)?login 場(chǎng)景中執(zhí)行塊賦值,就 只有 username 和 password 會(huì)被塊賦值。 因?yàn)橹挥兴鼈兂霈F(xiàn)在 login 的驗(yàn)證規(guī)則中。 另一方面,如果場(chǎng)景是 register , 這三個(gè)特性就都可以被塊賦值。
// 在登錄場(chǎng)景中 $model=new User('login'); if(isset($_POST['User'])) $model->attributes=$_POST['User']; // 在注冊(cè)場(chǎng)景中 $model=new User('register'); if(isset($_POST['User'])) $model->attributes=$_POST['User'];
那么為什么我們使用這樣一種策略來(lái)檢測(cè)特性是否安全呢? 背后的基 本原理就是:如果一個(gè)特性已經(jīng)有了一個(gè)或多個(gè)可檢測(cè)有效性的驗(yàn)證規(guī)則,那我們還擔(dān)心什么呢?
請(qǐng)記住,驗(yàn)證規(guī)則是 用于檢查用戶輸入的數(shù)據(jù),而不是檢查我們?cè)诖a中生成的數(shù)據(jù)(例如時(shí)間戳,自動(dòng)產(chǎn)生的主鍵)。 因此,不要 為那些不接受 最終用戶輸入的特性添加驗(yàn)證規(guī)則。
有時(shí)候,我們想聲明一個(gè)特性是安全的,即使我們沒(méi)有為它指定任何規(guī)則。 例如, 一篇文章的內(nèi)容可以接受用戶的任何輸入。我們可以使用特殊的 safe 規(guī)則實(shí)現(xiàn)此目的:
array('content', 'safe')
為了完成起見(jiàn),還有一個(gè)用于聲明一個(gè)屬性為不安全的 unsafe 規(guī)則:
array ('permission', 'unsafe')
unsafe 規(guī)則并不常用,它是我們之前定義的安全特性的一個(gè)例外 。
1.0 中的安全特性
在版本1.0中,決定一個(gè)數(shù)據(jù)項(xiàng)是否是安全的,基于一個(gè)名為 safeAttributes 方法的返回值 和數(shù)據(jù)項(xiàng)被指定的場(chǎng)景. 默認(rèn)的,這個(gè)方法返回所有公共成員變量作為 CFormModel 的安全特性,而它也返回了除了主鍵外, 表中 所有字段名作為 CActiveRecord的安全特性.我們可以根據(jù)場(chǎng)景重寫(xiě)這個(gè)方法來(lái)限制安全特性 .例如, 一個(gè)用戶模型可以包含很 多特性,但是在 login 場(chǎng)景.里,我們只能使用 username 和 password 特性.我們可以按照如下來(lái)指定這一限制 :
public function safeAttributes() { return array( parent::safeAttributes(), 'login' => 'username, password', ); }safeAttributes 方法更準(zhǔn)確的返回值應(yīng)該是如下結(jié)構(gòu)的 : array( // these attributes can be massively assigned in any scenario // that is not explicitly specified below 'attr1, attr2, ...', * // these attributes can be massively assigned only in scenario 1 'scenario1' => 'attr2, attr3, ...', * // these attributes can be massively assigned only in scenario 2 'scenario2' => 'attr1, attr3, ...', )
如果模型不是場(chǎng)景敏感的(比如,它只在一個(gè)場(chǎng)景中使用,或者所有場(chǎng)景共享了一套同樣的安全特性),返 回值可以是如 下那樣簡(jiǎn)單的字符串.
'attr1, attr2, ...'
而那些不安全的數(shù)據(jù)項(xiàng),我們需要使用獨(dú)立的賦值語(yǔ)句來(lái)分 配它們到相應(yīng)的特性.如下所示:
$model->permission='admin'; $model->id=1;4. 觸發(fā)驗(yàn)證
一旦模型被用戶提交的數(shù)據(jù)填充,我們就可以調(diào)用 CModel::validate() 出發(fā) 數(shù)據(jù)驗(yàn)證進(jìn)程。此方法返回一個(gè)指示驗(yàn)證是否成功的值。 對(duì) CActiveRecord 模型來(lái)說(shuō),驗(yàn)證也可以在我們調(diào)用其 CActiveRecord::save() 方法時(shí)自動(dòng)觸發(fā)。
我們可以使用 scenario 設(shè)置場(chǎng)景屬性,這樣,相應(yīng)場(chǎng)景的驗(yàn)證規(guī)則就會(huì)被 應(yīng)用。
驗(yàn)證是基于場(chǎng)景執(zhí)行的。 scenario 屬性指定了模型當(dāng)前用于的場(chǎng)景和當(dāng)前使用的驗(yàn)證規(guī)則集。 例如,在 login 場(chǎng)景中,我們只想驗(yàn)證用戶模型中的 username 和 password 輸入; 而在 register 場(chǎng)景中,我們需要驗(yàn)證更多的輸入,例如 email, address, 等。 下面的例子演示了如何在 register 場(chǎng)景中執(zhí)行驗(yàn)證:
// 在注冊(cè)場(chǎng)景中創(chuàng)建一個(gè) User 模型 。等價(jià)于: // $model=new User; // $model->scenario='register'; $model=new User('register'); // 將輸入的值填充到模型 $model->attributes=$_POST['User']; // 執(zhí)行驗(yàn)證 if($model->validate()) // if the inputs are valid ... else ...規(guī)則關(guān)聯(lián)的場(chǎng)景可以通過(guò)規(guī)則中的 on 選項(xiàng)指定。如果 on 選項(xiàng)未設(shè)置,則此規(guī)則會(huì)應(yīng)用于所有場(chǎng)景。例如: public function rules() { return array( array('username, password', 'required'), array('password_repeat', 'required', 'on'=>'register'), array('password', 'compare', 'on'=>'register'), ); }
第一個(gè)規(guī)則將應(yīng)用于所有場(chǎng)景,而第二個(gè)將只會(huì)應(yīng)用于 register 場(chǎng)景。
5. 提取驗(yàn)證錯(cuò)誤
驗(yàn)證完成 后,任何可能產(chǎn)生的錯(cuò)誤將被存儲(chǔ)在模型對(duì)象中。 我們可以通過(guò)調(diào)用 CModel::getErrors()和CModel::getError() 提取這些錯(cuò) 誤信息。 這兩個(gè)方法的不同點(diǎn)在于第一個(gè)方法將返回 所有 模型特性的錯(cuò)誤信息,而第二個(gè)將只返回 第一個(gè) 錯(cuò)誤信息。
6. 特性標(biāo)簽
當(dāng)設(shè)計(jì)表單時(shí),我們通常需要為每個(gè)表單域顯示一個(gè)標(biāo)簽。 標(biāo)簽告訴用戶他應(yīng)該在此表單域中填寫(xiě) 什么樣的信息。雖然我們可以在視圖中硬編碼一個(gè)標(biāo)簽, 但如果我們?cè)谙鄳?yīng)的模型中指定(標(biāo)簽),則會(huì)更加靈活方便。
默認(rèn)情況下 CModel 將簡(jiǎn)單的返回特性的名字作為其標(biāo)簽。這可以通過(guò)覆蓋 attributeLabels() 方法自定義。 正如在 接下來(lái)的小節(jié)中我們將看到的,在模型中指定標(biāo)簽會(huì)使我們能夠更快的創(chuàng)建出更強(qiáng)大的表單。
7. 創(chuàng)建動(dòng)作Action方法
創(chuàng)建好LoginForm 表單Model后,我們就可以為它編寫(xiě)用戶提交后的處理代碼(對(duì)應(yīng)到Controller中的某個(gè)Action方法) 。本例使用缺省的SiteController,對(duì)應(yīng)的action為actionLogin.
public function actionLogin() { $model=new LoginForm; // collect user input data if(isset($_POST['LoginForm'])) { $model->attributes=$_POST['LoginForm']; // validate user input and redirect to the previous page if valid if($model->validate() && $model->login()){ $this->render('index'); return; } } // display the login form $this->render('login',array('model'=>$model)); }
如上所示,我們首先創(chuàng)建了一個(gè) LoginForm 模型示例; 如果請(qǐng)求是一個(gè) POST 請(qǐng)求(意味著這個(gè)登錄表單被提交了 ),我們則使用提交的數(shù)據(jù) $_POST['LoginForm'] 填充 $model ;然后我們驗(yàn)證此輸入,如果驗(yàn)證成功,則顯示index 頁(yè)面。 如果驗(yàn)證失敗,或者此動(dòng)作被初次訪問(wèn),我們則渲染 login 視圖。
注意的我們修改了SiteController 的缺省 action為login.
/** * @var string sets the default action to be 'login' */ public $defaultAction='login';
因此用戶見(jiàn)到的第一個(gè)頁(yè)面為login頁(yè)面而非index頁(yè)面,只有在用戶輸入正確的用 戶名,本例使用固定的用戶名和密碼,參見(jiàn)UserIdentity類定義,實(shí)際應(yīng)用可以讀取數(shù)據(jù)庫(kù)或是LDAP服務(wù)器。
/** * UserIdentity represents the data needed to identity a user. * It contains the authentication method that checks if the provided * data can identity the user. */ class UserIdentity extends CUserIdentity { /** * Authenticates a user. * The example implementation makes sure if the username and password * are both 'demo'. * In practical applications, this should be changed to authenticate * against some persistent user identity storage (e.g. database). * @return boolean whether authentication succeeds. */ public function authenticate() { $users=array( // username => password 'demo'=>'demo', 'admin'=>'admin', ); if(!isset($users[$this->username])) $this->errorCode=self::ERROR_USERNAME_INVALID; else if($users[$this->username]!==$this->password) $this->errorCode=self::ERROR_PASSWORD_INVALID; else $this->errorCode=self::ERROR_NONE; return !$this->errorCode; } }
讓我們特別留意一下 login 動(dòng)作中出現(xiàn)的下面的 PHP 語(yǔ)句:
$model->attributes=$_POST ['LoginForm'];
正如我們?cè)?安全的特性賦值 中所講的, 這行代碼使用用戶提交的數(shù)據(jù)填充模型。 attributes 屬性由 CModel定義,它接受一個(gè)名值對(duì)數(shù)組并將其中的每個(gè)值賦給相應(yīng)的模型特性。 因此如果 $_POST ['LoginForm'] 給了我們這樣的一個(gè)數(shù)組,上面的那段代碼也就等同于下面冗長(zhǎng)的這段 (假設(shè)數(shù)組中存在所有所需的特 性):
$model->username=$_POST['LoginForm']['username']; $model->password=$_POST ['LoginForm']['password']; $model->rememberMe=$_POST['LoginForm'] ['rememberMe'];
8. 構(gòu)建視圖
編寫(xiě) login 視圖是很簡(jiǎn)單的,我們以一個(gè) form 標(biāo)記開(kāi)始,它的 action 屬性應(yīng)該是前面講述的 login 動(dòng)作的URL。 然后我們需要為 LoginForm 類中聲明的屬性插入標(biāo)簽和表單域。最后, 我們插入 一個(gè)可由用戶點(diǎn)擊提交此表單的提交按鈕。所有這些都可以用純HTML代碼完成。
Yii 提供了幾個(gè)助手(helper)類簡(jiǎn)化 視圖編寫(xiě)。例如, 要?jiǎng)?chuàng)建一個(gè)文本輸入域,我們可以調(diào)用 CHtml::textField(); 要?jiǎng)?chuàng)建一個(gè)下拉列表,則調(diào)用 CHtml::dropDownList()。
信息: 你可能想知道使用助手的好處,如果它們所需的代碼量和直接寫(xiě)純HTML的代碼量相當(dāng)?shù)?話。 答案就是助手可以提供比 HTML 代碼更多的功能。例如, 如下代碼將生成一個(gè)文本輸入域,它可以在用戶修改了其值時(shí)觸 發(fā)表單提交動(dòng)作。
CHtml::textField($name,$value,array('submit'=>''));
不然的話你就 需要寫(xiě)一大堆 JavaScript 。
下面,我們使用 CHtml 創(chuàng)建一個(gè)登錄表單。我們假設(shè)變量 $model 是 LoginForm 的實(shí)例 。
<center class="form"> <?php echo CHtml::beginForm(); ?> <?php echo CHtml::errorSummary($model); ?> <center class="row"> <?php echo CHtml::activeLabel($model,'username'); ?> <?php echo CHtml::activeTextField($model,'username') ?> </center> <center class="row"> <?php echo CHtml::activeLabel($model,'password'); ?> <?php echo CHtml::activePasswordField($model,'password') ?> </center> <center class="row rememberMe"> <?php echo CHtml::activeCheckBox($model,'rememberMe'); ?> <?php echo CHtml::activeLabel($model,'rememberMe'); ?> </center> <center class="row submit"> <?php echo CHtml::submitButton('Login'); ?> </center> <?php echo CHtml::endForm(); ?> </center><!-- form -->
上述代碼生成了一個(gè)更加動(dòng)態(tài)的表單,例如, CHtml::activeLabel() 生成一個(gè)與 指定模型的特性相關(guān)的標(biāo)簽。 如果此特性有一個(gè)輸入錯(cuò)誤,此標(biāo)簽的CSS class 將變?yōu)?error,通過(guò) CSS 樣式改變了標(biāo)簽的外 觀。 相似的,CHtml::activeTextField() 為指定模型的特性生成一個(gè)文本輸入域,并會(huì)在錯(cuò)誤發(fā)生時(shí)改變它的 CSS class。
如果我們使用由 yiic 腳本生提供的 CSS 樣式文件,生成的表單就會(huì)像下面這樣:
CSS 樣式定義在css目錄下,本例使用的為Yii缺省的樣式。
從版本 1.1.1 開(kāi)始,提供了一個(gè)新的小物件 CActiveForm 以簡(jiǎn)化表單創(chuàng)建。 這個(gè)小物件可同時(shí)提供客戶端及服務(wù)器端無(wú)縫的、一致的驗(yàn)證。使用 CActiveForm, 上面的代 碼可重寫(xiě)為:
<center class="form"> <?php $form=$this->beginWidget('CActiveForm'); ?> <?php echo $form->errorSummary($model); ?> <center class="row"> <?php echo $form->label($model,'username'); ?> <?php echo $form->textField($model,'username') ?> </center> <center class="row"> <?php echo $form->label($model,'password'); ?> <?php echo $form->passwordField($model,'password') ?> </center> <center class="row rememberMe"> <?php echo $form->checkBox($model,'rememberMe'); ?> <?php echo $form->label($model,'rememberMe'); ?> </center> <center class="row submit"> <?php echo CHtml::submitButton('Login'); ?> </center> <?php $this->endWidget(); ?> </center><!-- form -->
從下篇開(kāi)始將逐個(gè)介紹Yii框架支持的UI組件包括CActiveForm的用法。
以上就是PHP開(kāi)發(fā)框架Yii Framework教程(8) 使用FormModel的內(nèi)容,更多相關(guān)內(nèi)容請(qǐng)關(guān)注PHP中文網(wǎng)(miracleart.cn)!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











Windows 11 ?? Windows 10 PC? ????? ?? ???? ??? ?? ??? ????? ??? ?? ??? ???? ?? ??? ?????. ??? ?? ??? ???? ?? ?????? ????? ???? ??? ??? ? ????. ??? ?? ??? ???? ??? ??? ??? ??? ? ? ???? ??? ??? ? ????. ??? ?? ??? ???? ?? ??? ??? ???? ????? ?????. ??? ??? ??? ?? ? ?? ??? ????. ? ?? ??? ?? ??? ?? ???? ? ??? ?? Microsoft?? ???? SetupDiag?? ?? ??? ??? ? ? ????.

.NET Framework 4? ???? ?? ???? Windows?? ?? ??? ??????? ???? ? ?????. ??? .NET Framework 4? ?????? ???? ?? ?? ???? ?? ????? ??? ???? "?? ?? 0x800c0006?? ?? ????? ???? ??? .NET Framework 4? ???? ?????"?? ?? ???? ????? ??????. ??? .NETFramework4? ???? ???? ? ??? ????? ??? ??? ?? ????.
![SCNotification? ??? ?????. [??? ?? 5??]](https://img.php.cn/upload/article/000/887/227/168433050522031.png?x-oss-process=image/resize,m_fill,h_207,w_330)
Windows ???? ???? ??? ??? SCNotification? ??? ??????. ??? ??? ? ????. SCNotification.exe? ?? ?? ? ???? ??? ?? PC? ??? ??? ??? ???? Microsoft ??? ?? ?????. ? ??? ??? ?? ??? ????? ??? ????. ??? ?? SCNotification? ??? ??? ??? ???? ?? ?? clr20r3?? ??? ? ????. ? ????? SCNotification? ??? ???? ?? ??? ?? ??? ???? ?? ??? ? ?? ??? ???????. SCNotification.e? ?????

Microsoft.NET ?? 4.5.2, 4.6 ?? 4.6.1? ??? Microsoft Windows ???? Microsoft?? ?? ?? ????? ?? ?????? ????? ??? ?? ??? Microsoft Framework? ???? ???. Microsoft? ??? ? ?? ????? ?? 2022? 4? 26?? ??? ?????. ?? ??? ???? ?? ??? "?? ?? ?? ?? ??"? ?? ? ????. ???? ??? ??? Windows ????? ?? ?? ??? ?????. ??? ???? .NET Framework 4.8? ?? ?? ??? ?????? ?? ???? ????. ???? ?????? ?? ???

?? ??? ???? ????, ????, ???? ??? ?? ??? ?? ??? ??? ?????. ??? ??? ??? ??? ??? ?? ???? ??? ?? ??? ??? ?? ??? ?? ??. ??? ?? ??? ??? ?? ??, ?? ? TV ?? ??, ????? ??? ? ?? ???? ?? ?????. ????? ??? ????? ??? ?????? ???? ?? ?? ??? ?????. ?? ?? ??? PHP? Yii2, Ph? ?? ??? PHP ????? ? ?? ???? ?????.

Windows 11? KB5012643? ??? ????? ??? ??? ??? ?? ?? ??? ?? ???? ? ???? ?????. ? ??? ??? Microsoft? ???? ??? ??? ?? ??? ???? ?? ??? ??? ????. ??, ??? ? ?? ??? ? ??? ???? ? Microsoft? ? ?? ????? ??? ????? ? ?? ??? ???????. Windows 11 ?? 22000.652? ?? ? ?? ?? ?? ??? ?? ??? Windows 11 ????? ?? .NET Framework 3.5 ?? ????? ???? ???? ? ??? ??? ? ??? ?????. ??? ? ???? ??? ??? ???.

Yii ?????? ? ?????? ?? ????? ????? ?? ??? ??? ?? ??? ???? ?? ?? PHP ? ?????? ????????. ??? ??? ??? ?? ?? ? ?????. Yii ???????? SQL? ??? ??? ???? ??????? ????? ???? ????? ???? ??? ? ????. Yii ?????? ?? ???? ?? ActiveRecord ??, QueryBuilder ??, ?? ?? ? ?? SQL ?? ??? ?????.

???? ?? ???? ?? ? ?????? ??? ?? ??? ?? ???? ????. ???? ?? ?????? ???? ?? ???? ???? ? ?? ????? ????? ??? ?????? ?????. Yii? ??? ??? ??? ??? ???? ???? ??? PHP ????????. Yii3? Yii2? ???? ??? ?? ??? ?? ????? Yii ?????? ??? ?????. ?? ???? Yii3 ?????? ???? PHP ??????? ???? ??? ???????.
