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

Gathering common PHP front-end syntax

coldplay.xixi
Release: 2023-04-08 18:58:01
forward
2539 people have browsed it

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;)"
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template