← 返回
安全合规 中文

PHP

Write solid PHP avoiding type juggling traps, array quirks, and common security pitfalls.
编写健壮的PHP代码,规避类型转换陷阱、数组怪癖及常见安全漏洞。
ivangdavila
安全合规 clawhub v1.0.1 1 版本 99955.6 Key: 无需
★ 5
Stars
📥 2,152
下载
💾 180
安装
1
版本
#latest

概述

Quick Reference

TopicFile
-------------
Loose typing, ==, ===, type juggling, strict_typestypes.md
Associative arrays, iteration, array functionsarrays.md
Traits, interfaces, visibility, late static bindingoop.md
Encoding, interpolation, heredoc, regexstrings.md
Exceptions, error handling, @ operatorerrors.md
SQL injection, XSS, CSRF, input validationsecurity.md
PHP 8+ features, attributes, named args, matchmodern.md

Critical Rules

  • == coerces types: "0" == false is true — always use === for strict comparison
  • in_array($val, $arr) uses loose comparison — pass true as third param for strict
  • strpos() returns 0 for match at start — use === false not !strpos()
  • Never concatenate SQL — use prepared statements with PDO
  • htmlspecialchars($s, ENT_QUOTES) all output — prevents XSS
  • isset() returns false for null — use array_key_exists() to check key exists
  • foreach ($arr as &$val) — unset $val after loop or last ref persists
  • static:: late binding vs self:: early binding — static respects overrides
  • @ suppresses errors — avoid, makes debugging impossible
  • Catch Throwable for both Error and Exception — PHP 7+
  • declare(strict_types=1) per file — enables strict type checking
  • strlen() counts bytes — use mb_strlen() for UTF-8 character count
  • Objects pass by reference-like handle — clone explicitly with clone $obj
  • array_merge() reindexes numeric keys — use + operator to preserve keys

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-28 21:55 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,215 📥 266,506
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,358 📥 318,292
productivity

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 438 📥 147,628