Home  >  Article  >  Backend Development  >  Gathering common PHP front-end syntax

Gathering common PHP front-end syntax

coldplay.xixi
coldplay.xixiforward
2020-06-08 09:41:532449browse

Gathering common PHP front-end syntax

php common front-end syntaxCollection

The following is the common front-end php syntax:

// 定义变量
<!--{eval $colSize = sizeof($navlist);}-->
<!--{eval $vip_level_points = array(0, 10000, 20000, 35000, 50000, 75000);}-->//数组
<!--{eval $cur_level = $_G[viplevel];}-->
 
// 输出变量
$colSize
<!--{eval echo $cur_level + 2;}-->
<!--{eval echo $cur_level < 7 ? &#39;vip-gray&#39; : &#39;&#39;;}-->
 
{$item[&#39;icon&#39;]}             // 输出对象值
{$iconColor[$index]}        // 直接输出数组值
{echo $iconColor[$index%3]} // 输出计算后的数组值
// 三目运算
<!--{eval $level_diff_point += ($cur_level == $highest_level - 1 ? 28 : 0);}-->
 
// 获取数组长度
<!--{eval $colSize = sizeof($navlist);}-->
or
<!--{eval $colSize = count($navlist);}-->
 
// 数据循环
<!--{loop $navlist $item}-->
      <div class="text-color-6e6 title-text">{$item[&#39;desc&#39;]}</div>
<!--{/loop}-->
 
// 逻辑判断if else if
<!--{if $_GET[&#39;from&#39;]=="mobileapp"}-->
<h1>手机访问</h1>
<!--{else}-->
<h1>非手机访问</h1>
<!--{/if}-->
 
// js获取php变量
url = &#39;$_config_di["login"]["h5"]&#39;;
 
οnclick="redirectLink(&#39;{$_config_di[&#39;forum&#39;]}/index1.html&#39;)"

Recommended tutorial: "PHP Video Tutorial"

The above is the detailed content of Gathering common PHP front-end syntax. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete