当前位置:网站首页>The simplicity of laravel
The simplicity of laravel
2022-07-03 19:41:00 【siner. li】
Use an array to find the required value based on the keys you have
// It is bad
$ceshi = 'epub';
if ($ceshi === 'pdf') {
$type = 'book';
} else if ($ceshi === 'epub') {
$type = 'book';
} else if ($ceshi === 'license') {
$type = 'license';
} else if ($ceshi === 'artwork') {
$type = 'creative';
} else if ($ceshi === 'song') {
$type = 'creative';
} else if ($ceshi === 'physical') {
$type = 'physical';
}
dd($type);
Output : “book”
// The recommended
$ceshi = 'epub';
$type = [
'pdf' => 'book',
'epub' => 'book',
'license' => 'license',
'artwork' => 'creative',
'song' => 'creative',
'physical' => 'physical',
][$ceshi];
dd($type);
Output : “book”
Use short operators
// It is bad
// truthy test
if (! $foo) {
$foo = 'bar';
}
// null test
if (is_null($foo)) {
$foo = 'bar';
}
// isset test
if (! isset($foo)) {
$foo = 'bar';
}
// elegant
// truthy test
$foo = $foo ?: 'bar';
// null test
$foo = $foo ?? 'bar';
// PHP 7.4
$foo ??= 'bar';
// isset test
$foo = $foo ?? 'bar';
// PHP 7.4
$foo ??= 'bar';
边栏推荐
- 4. Data binding
- 2022-06-30 網工進階(十四)路由策略-匹配工具【ACL、IP-Prefix List】、策略工具【Filter-Policy】
- [wallpaper] (commercially available) 70 wallpaper HD free
- Chapter 1: King Shehan miscalculated
- Typora charges, WTF? Still need support
- Summary of 90 day learning materials and notes of Zhang Fei's actual electronic hardware engineer
- Next spread
- 第二章:求长方体数组,指定区间内的完全数,改进指定区间内的完全数
- 第一章:喝汽水,阶梯电费计算,阶梯电费计算函数,个人所税,求解平方根不等式,简化求解平方根不等式,求解调和级数不等式,解不等式:d<1+1/2-1/3+1/4+1/5-1/6+..士1/n
- 第一章:拓广同码小数和s(d, n)
猜你喜欢
![2022-06-30 advanced network engineering (XIV) routing strategy - matching tools [ACL, IP prefix list], policy tools [filter policy]](/img/b6/5d6b946d8001e2d73c2cadbdce72fc.png)
2022-06-30 advanced network engineering (XIV) routing strategy - matching tools [ACL, IP prefix list], policy tools [filter policy]
![[wallpaper] (commercially available) 70 wallpaper HD free](/img/21/6802da1056a18157b15de85df60cf5.jpg)
[wallpaper] (commercially available) 70 wallpaper HD free

These problems should be paid attention to in the production of enterprise promotional videos

2022-06-25 advanced network engineering (XI) IS-IS synchronization process of three tables (neighbor table, routing table, link state database table), LSP, cSNP, psnp, LSP

Xctf attack and defense world crypto master advanced area olddriver

PR 2021 quick start tutorial, material import and management

2022-06-30 網工進階(十四)路由策略-匹配工具【ACL、IP-Prefix List】、策略工具【Filter-Policy】

04 -- QT OpenGL two sets of shaders draw two triangles

Kubernetes cluster builds efk log collection platform

BOC protected tryptophan porphyrin compound (TAPP Trp BOC) Pink Solid 162.8mg supply - Qiyue supply
随机推荐
第一章: 舍罕王失算
Basic principle of LSM tree
2022-06-27 advanced network engineering (XII) IS-IS overhead type, overhead calculation, LSP processing mechanism, route revocation, route penetration
Phpstudy set LAN access
BOC protected amino acid porphyrins TAPP ala BOC, TAPP Phe BOC, TAPP Trp BOC, Zn · TAPP ala BOC, Zn · TAPP Phe BOC, Zn · TAPP Trp BOC Qiyue
unittest框架基本使用
Valentine's Day - make an exclusive digital collection for your lover
2022-06-25 网工进阶(十一)IS-IS-三大表(邻居表、路由表、链路状态数据库表)、LSP、CSNP、PSNP、LSP的同步过程
Chapter 2: 4-digit Kaplan number, search even digit Kaplan number, search n-digit 2-segment sum square number, m-digit ingenious square number without 0, specify the number to form a 7-digit square nu
Zhang Fei hardware 90 day learning notes - personal records on day 4, please see my personal profile / homepage for the complete
第二章:4位卡普雷卡数,搜索偶数位卡普雷卡数,搜索n位2段和平方数,m位不含0的巧妙平方数,指定数字组成没有重复数字的7位平方数,求指定区间内的勾股数组,求指定区间内的倒立勾股数组
第一章:求n的阶乘n!
01 - QT OpenGL display OpenGL window
Cesiumjs 2022 ^ source code interpretation [7] - Analysis of the request and loading process of 3dfiles
kubernetes集群搭建efk日志收集平台
Bright purple crystal meso tetra (4-aminophenyl) porphyrin tapp/tapppt/tappco/tappcd/tappzn/tapppd/tappcu/tappni/tappfe/tappmn metal complex - supplied by Qiyue
2022-06-30 网工进阶(十四)路由策略-匹配工具【ACL、IP-Prefix List】、策略工具【Filter-Policy】
2022-06-28 advanced network engineering (XIII) IS-IS route filtering, route summary, authentication, factors affecting the establishment of Isis neighbor relations, other commands and characteristics
论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding
Use unique_ PTR forward declaration? [repetition] - forward declaration with unique_ ptr? [duplicate]