<本体>"/> select<本体>">
検索
ホームページバックエンド開発PHPチュートリアルthinkphp はタグ ライブラリを修正して書き込み、エディターを使用します

thinkphp はタグ ライブラリを変更して書き込み、エディタを使用します
ビュー ディレクトリに Index_aaa.html を作成します

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="dec"><!DOCTYPE html></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"><html></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="tag"><head></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="tag"><meta</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"UTF-8"</span><span class="tag">></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="tag"><title></span><span class="pln">select</span><span class="tag"></title></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="tag"></head></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="tag"><body></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="tag"><tagLib</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"html"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="tag"><html:select</span><span class="pln"> </span><span class="atn">options</span><span class="pun">=</span><span class="atv">"address"</span><span class="pln"> </span><span class="atn">selected</span><span class="pun">=</span><span class="atv">"sh"</span><span class="pln">  </span><span class="atn">values</span><span class="pun">=</span><span class="atv">"address"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="tag"></body></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"></html></span></code></li></ol>

IndexController.class.php に関数を書き込みます

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> aaa</span><span class="pun">(){</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        $this</span><span class="pun">-></span><span class="pln">assign</span><span class="pun">(</span><span class="str">"address"</span><span class="pun">,[</span><span class="str">"sh"</span><span class="pun">=></span><span class="pln"> </span><span class="str">"上海"</span><span class="pun">,</span><span class="str">"天津"</span><span class="pun">,</span><span class="str">"北京"</span><span class="pun">,</span><span class="str">"郑州"</span><span class="pun">]);</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        $this</span><span class="pun">-></span><span class="pln">display</span><span class="pun">();</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">    </span><span class="pun">}</span></code></li></ol>


このファイルを変更してタグ ライブラリを作成します


values='0'

の問題を解決するために出力項目をすべてvalに変更し、valuesの値をオプションの値と等しくします


新しいタグを作成します

'ms'=>array('attr'=> ;'id,name, options,selected','close'=>0)

html:ms id= "aa" 名前="uu" オプション="アドレス" 選択済み ="北京"/>br>

改造コード選択 値は任意に記述可能


<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">  </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> _ms</span><span class="pun">(</span><span class="pln">$tag</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        $name       </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'name'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        $options    </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'options'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        $id         </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">        $selected   </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'selected'</span><span class="pun">];</span><span class="pln">      </span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">.=</span><span class="str">'<?php foreach($'</span><span class="pun">.</span><span class="pln">$options</span><span class="pun">.</span><span class="str">' as $val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">.=</span><span class="str">'<?php if("'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">'"==$val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'</select>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        </span><span class="kwd">return</span><span class="pln"> $parseStr</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">    </span><span class="pun">}</span></code></li></ol>

選択した値に応じて決定可能

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">    </span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> _ms</span><span class="pun">(</span><span class="pln">$tag</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        $name       </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'name'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        $options    </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'options'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">        $id         </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">        $selected   </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'selected'</span><span class="pun">];</span><span class="pln">      </span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">.=</span><span class="str">'<?php foreach($'</span><span class="pun">.</span><span class="pln">$options</span><span class="pun">.</span><span class="str">' as $val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">          </span><span class="com">/*  $parseStr .='<?php if("'.$selected.'"==$val) { ?>';*///selected的值可以随便写</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">.=</span><span class="str">'<?php if($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">'==$val) { ?>'</span><span class="pun">;</span><span class="com">//值可以先分配再写</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">             $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'</select>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">        </span><span class="kwd">return</span><span class="pln"> $parseStr</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">    </span><span class="pun">}</span></code></li></ol>

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> aaa</span><span class="pun">(){</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        $this</span><span class="pun">-></span><span class="pln">assign</span><span class="pun">(</span><span class="str">"address"</span><span class="pun">,[</span><span class="str">"上海"</span><span class="pun">,</span><span class="str">"天津"</span><span class="pun">,</span><span class="str">"北京"</span><span class="pun">,</span><span class="str">"郑州"</span><span class="pun">]);</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        $this</span><span class="pun">-></span><span class="pln">assign</span><span class="pun">(</span><span class="str">"sh"</span><span class="pun">,</span><span class="str">"天津"</span><span class="pun">);</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        $this</span><span class="pun">-></span><span class="pln">display</span><span class="pun">();</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">    </span><span class="pun">}</span></code></li></ol>

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="tag"><tagLib</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"html"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"><html:ms</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"aa"</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"uu"</span><span class="pln"> </span><span class="atn">options</span><span class="pun">=</span><span class="atv">"address"</span><span class="pln"> </span><span class="atn">selected</span><span class="pun">=</span><span class="atv">"sh"</span><span class="tag">/><br></span></code></li></ol>

フレームワーク自体でも実現できます


赤い線の $key を $val に変更することもできますが、システムには少し変更が加えられています。

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> _select</span><span class="pun">(</span><span class="pln">$tag</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        $name       </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'name'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        $options    </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'options'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        $values     </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'values'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">        $output     </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'output'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">        $multiple   </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'multiple'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">        $id         </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">        $size       </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'size'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">        $first      </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'first'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">        $selected   </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'selected'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">        $style      </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'style'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        $ondblclick </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'dblclick'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">		$onchange	</span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'change'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">        </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$multiple</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" ondblclick="'</span><span class="pun">.</span><span class="pln">$ondblclick</span><span class="pun">.</span><span class="str">'" onchange="'</span><span class="pun">.</span><span class="pln">$onchange</span><span class="pun">.</span><span class="str">'" multiple="multiple" class="'</span><span class="pun">.</span><span class="pln">$style</span><span class="pun">.</span><span class="str">'" size="'</span><span class="pun">.</span><span class="pln">$size</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">        </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">        	$parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" onchange="'</span><span class="pun">.</span><span class="pln">$onchange</span><span class="pun">.</span><span class="str">'" ondblclick="'</span><span class="pun">.</span><span class="pln">$ondblclick</span><span class="pun">.</span><span class="str">'" class="'</span><span class="pun">.</span><span class="pln">$style</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">        </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">        </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$first</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">            $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option value="" >'</span><span class="pun">.</span><span class="pln">$first</span><span class="pun">.</span><span class="str">'</option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">        </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">        </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$options</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php  foreach($'</span><span class="pun">.</span><span class="pln">$options</span><span class="pun">.</span><span class="str">' as $key=>$val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">            </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$selected</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php if(!empty($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && ($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">' == $val || in_array($key,$'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">'))) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php }else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">            </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">            </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">        </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$values</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php  for($i=0;$i<count($'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">');$i++) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">            </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$selected</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php if(isset($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && ((is_string($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && $'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">' == $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i]) || (is_array($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && in_array($'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i],$'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">')))) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i] ?>"><?php echo $'</span><span class="pun">.</span><span class="pln">$output</span><span class="pun">.</span><span class="str">'[$i] ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php }else { ?><option value="<?php echo $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i] ?>"><?php echo $'</span><span class="pun">.</span><span class="pln">$output</span><span class="pun">.</span><span class="str">'[$i] ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">            </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">                $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option value="<?php echo $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i] ?>"><?php echo $'</span><span class="pun">.</span><span class="pln">$output</span><span class="pun">.</span><span class="str">'[$i] ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln">            </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln">            $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln">        </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln">        $parseStr   </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'</select>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln">        </span><span class="kwd">return</span><span class="pln"> $parseStr</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln">    </span><span class="pun">}</span></code></li></ol>

を選択した後、ueditor を導入して js に配置し、ueditor.config.js を次のコードに変更します

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">    window</span><span class="pun">.</span><span class="pln">UEDITOR_HOME_URL </span><span class="pun">=</span><span class="pln"> </span><span class="str">"/Public/js/ueditor/"</span><span class="pun">;</span><span class="pln">  </span></code></li></ol>



Baidu エディタを thinkphp に入れる

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln">    $parseStr   </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<script id="container" name="content" type="text/plain">这里写你的初始化内容</script><script type="text/javascript" src="__ROOT__/Public/js/ueditor/ueditor.config.js"></script><script type="text/javascript" src="__ROOT__/Public/js/ueditor/ueditor.all.js"></script><script type="text/javascript">        var ue = UE.getEditor("container",{emotionLocalization:true,lang:"zh-cn",initialFrameWidth:"80%",initialFrameHeight:320,textarea:"content",initialContent:"欢迎留言!",    autoClearinitialContent:true}); </script>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln">            </span></code></li></ol>

次に Index_aaa.html に表示するコードを記述します

<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="tag"><tagLib</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"html"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"><html:editor</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"UEDITOR"</span><span class="tag">></html:editor></span></code></li></ol>







Wiz Notes (Wiz) より



声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
华为GT3 Pro和GT4的差异是什么?华为GT3 Pro和GT4的差异是什么?Dec 29, 2023 pm 02:27 PM

许多用户在选择智能手表的时候都会选择的华为的品牌,其中华为GT3pro和GT4都是非常热门的选择,不少用户都很好奇华为GT3pro和GT4有什么区别,下面就就给大家介绍一下二者。华为GT3pro和GT4有什么区别一、外观GT4:46mm和41mm,材质是玻璃表镜+不锈钢机身+高分纤维后壳。GT3pro:46.6mm和42.9mm,材质是蓝宝石玻璃表镜+钛金属机身/陶瓷机身+陶瓷后壳二、健康GT4:采用最新的华为Truseen5.5+算法,结果会更加的精准。GT3pro:多了ECG心电图和血管及安

php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

修复:截图工具在 Windows 11 中不起作用修复:截图工具在 Windows 11 中不起作用Aug 24, 2023 am 09:48 AM

为什么截图工具在Windows11上不起作用了解问题的根本原因有助于找到正确的解决方案。以下是截图工具可能无法正常工作的主要原因:对焦助手已打开:这可以防止截图工具打开。应用程序损坏:如果截图工具在启动时崩溃,则可能已损坏。过时的图形驱动程序:不兼容的驱动程序可能会干扰截图工具。来自其他应用程序的干扰:其他正在运行的应用程序可能与截图工具冲突。证书已过期:升级过程中的错误可能会导致此issu简单的解决方案这些适合大多数用户,不需要任何特殊的技术知识。1.更新窗口和Microsoft应用商店应用程

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么判断有没有小数点php怎么判断有没有小数点Apr 20, 2022 pm 08:12 PM

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

mPDF

mPDF

mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。

SublimeText3 Linux 新バージョン

SublimeText3 Linux 新バージョン

SublimeText3 Linux 最新バージョン

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

DVWA

DVWA

Damn Vulnerable Web App (DVWA) は、非常に脆弱な PHP/MySQL Web アプリケーションです。その主な目的は、セキュリティ専門家が法的環境でスキルとツールをテストするのに役立ち、Web 開発者が Web アプリケーションを保護するプロセスをより深く理解できるようにし、教師/生徒が教室環境で Web アプリケーションを教え/学習できるようにすることです。安全。 DVWA の目標は、シンプルでわかりやすいインターフェイスを通じて、さまざまな難易度で最も一般的な Web 脆弱性のいくつかを実践することです。このソフトウェアは、

PhpStorm Mac バージョン

PhpStorm Mac バージョン

最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール