4 回答

TA贡献1803条经验 获得超6个赞
我会谨慎地称val()为纯粹的邪恶。
潜在的不安全输入。
传递不受信任的参数是失败的一种方法。确保参数(或参数的一部分)完全可信通常不是一项简单的任务。 诡计。
使用val()使代码更聪明,因此更难以理解。引用布赖恩·克尼汉的话 调试的难度是编写代码的第一步的两倍。因此,如果您尽可能聪明地编写代码,那么根据定义,您就没有足够的智能来调试它。"
没有经验的开发人员谁使用它没有足够的考虑。
有时val()是唯一/正确的解决方案。 在大多数情况下,人们应该尝试其他的东西。 如果不确定,去2。 否则, 非常小心。

TA贡献1946条经验 获得超3个赞

TA贡献1862条经验 获得超7个赞
Eval()在任何时候都是同样邪恶的。

TA贡献1853条经验 获得超9个赞
$json = str_replace(array( 'enum', '(', ')', "'"), array) '', '[', ']', "'"), $type);$result = json_decode($json);
$extract_regex = '/ (?<=,|enum\() # Match strings that follow either a comma, or the string "enum("... \' # ...then the opening quote mark... (.*?) # ...and capture anything... \' # ...up to the closing quote mark... /x';preg_match_all($extract_regex, $type, $matches);$result = $matches[1];
- 4 回答
- 0 关注
- 488 浏览
添加回答
举报