--- id: php-operators title: "PHP Operators" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["PHP μ—°μ‚°μž"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["php", "programming", "w3schools", "operators"] raw_sources: ["https://www.w3schools.com/php/php_operators.asp"] applied_in: [] github_commit: "" --- # [[PHP Operators]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) PHP distinguishes `==` (equal) from `===` (identical) at the type level, not just the value level β€” `$x === $y` requires BOTH the value AND the data type to match, meaning `5 == "5"` is true but `5 === "5"` is false, a distinction that extends identically to array comparison operators too. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **8 operator groups** β€” Arithmetic, Assignment, Comparison, Increment/Decrement, Logical, String, Array, Conditional. [S1] - **`==` vs `===`** β€” equal (loose, value only) vs. identical (strict, value + type). [S1] - **`<=>`** (spaceship, PHP 7+) β€” returns negative/zero/positive based on relative order. [S1] - **Pre vs. post increment** β€” `++$x` returns the NEW value; `$x++` returns the OLD value, both then incrementing. [S1] - **String operators** β€” `.` (concat), `.=` (concat-assign). [S1] - **Array operators** β€” `+` (union), `==`/`===` (equality/identity with type-sensitivity difference). [S1] - **`?:`** (ternary) and **`??`** (null coalescing, PHP 7+) β€” conditional shorthand operators. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Comparison table includes: `==`, `===`, `!=`, `<>`, `!==`, `>`, `<`, `>=`, `<=`, `<=>` (spaceship). [S1] - Increment/decrement: `++$x` (pre-increment: increments then returns), `$x++` (post-increment: returns then increments). [S1] - Logical operators: `and`/`&&`, `or`/`||`, `xor`, `!`. [S1] - Null coalescing: `$x = expr1 ?? expr2;` β€” `expr2` used if `expr1` doesn't exist or is NULL. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **== 와 ===의 차이**: κ°’λ§Œ 비ꡐ(==)ν•˜λŠ” 것과 κ°’+νƒ€μž…μ„ λͺ¨λ‘ 비ꡐ(===)ν•˜λŠ” 것이 λ°°μ—΄ 비ꡐ에도 λ™μΌν•˜κ²Œ μ μš©λœλ‹€λŠ” 점이 λͺ…μ‹œλ¨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” null 병합 μ—°μ‚°μž(??)κ°€ κΈ°λ³Έκ°’ μ„€μ • λ‘œμ§μ—μ„œ 자주 μ“°μ΄λŠ” μ‹€μ „ νŒ¨ν„΄μ΄λ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Null coalescing operator for default values (PHP): ```php $x = $expr1 ?? "default value"; // uses $expr1 unless it's NULL/unset ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[PHP Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[PHP If Else]], [[PHP If Operators]], [[PHP If Shorthand]] - **μ°Έμ‘° λ§₯락:** λͺ¨λ“  μ—°μ‚°μžμ˜ κ°œμš” β€” 쑰건문(If Else) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” PHP Operators β€” https://www.w3schools.com/php/php_operators.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "PHP Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).