当前位置:网站首页>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';
边栏推荐
- February 14-20, 2022 (osgear source code debugging +ue4 video +ogremain source code transcription)
- Rd file name conflict when extending a S4 method of some other package
- Leetcode 1189. Maximum number of balloons (special character count)
- P1891 crazy LCM (Euler function)
- Find a line in a file and remove it
- Difference between surface go1 and surface GO2 (non professional comparison)
- 05 -- QT OpenGL draw cube uniform
- Utilisation de base du cadre unitest
- PR 2021 quick start tutorial, how to create new projects and basic settings of preferences?
- Day10 -- forced login, token refresh and JWT disable
猜你喜欢

kubernetes集群搭建efk日志收集平台

BOC protected tryptophan porphyrin compound (TAPP Trp BOC) Pink Solid 162.8mg supply - Qiyue supply

第一章:求奇因数代数和,求同吗小数和s(d, n),简化同码小数和s(d, n),拓广同码小数和s(d, n)

Recommend a GIF processing artifact less than 300K - gifsicle (free download)

第一章:简化同码小数和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]

What is the content of game modeling

Thesis study - 7 Very Deep Convolutional Networks for Large-Scale Image Recognition (3/3)

Chapter 1: drinking soft drinks, step tariff calculation, step tariff calculation function, personal income tax, solving square root inequality, simplifying solving square root inequality, solving dem

Chapter 2: find the classical solution of the maximum Convention and the least common multiple of a and B, find the conventional solution of the maximum Convention and the least common multiple of a a
随机推荐
QT -- qfile file read / write operation
Chapter 1: recursively find the factorial n of n!
Go home early today
IPv6 experiment
During MySQL installation, the download interface is empty, and the components to be downloaded are not displayed. MySQL installer 8.0.28.0 download interface is empty solution
JMeter connection database
Pecan - route
10 smart contract developer tools that miss and lose
5. MVVM model
Day11 ---- 我的页面, 用户信息获取修改与频道接口
Professional interpretation | how to become an SQL developer
原生表格-滚动-合并功能
Pecan — Overview
Find a line in a file and remove it
CMD implements the language conversion of locale non Unicode programs
I didn't cancel
Meso tetra [P - (p-n-carbazole benzylidene imino)] phenylporphyrin (tcipp) /eu (tcipp) [pc( α- 2-oc8h17) 4] and euh (tcipp) [pc (a-2-oc8h17) 4] supplied by Qiyue
Unittest framework is basically used
03 -- QT OpenGL EBO draw triangle
2022-07-02 advanced network engineering (XV) routing policy - route policy feature, policy based routing, MQC (modular QoS command line)