--- id: php-strings title: "PHP Strings" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["single vs double quotes", "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", "strings", "quotes"] raw_sources: ["https://www.w3schools.com/php/php_string.asp"] applied_in: [] github_commit: "" --- # [[PHP Strings]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Double and single quotes are NOT interchangeable in PHP β€” double quotes interpolate variables and support rich escape sequences (`\n`, `\t`) at a slight performance cost, while single quotes output everything literally (even `$x` prints as `$x`, not its value) and only support `\'`/`\\`, making single quotes both faster and safer for constant strings with no variables. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Double quotes** β€” substitute variable values; support many escape sequences (`\n`, `\r`, `\t`, `\$`, `\"`). [S1] - **Single quotes** β€” output text literally, including `$var` syntax as-is; only `\'` and `\\` are recognized escapes. [S1] - **Performance** β€” single quotes are slightly faster (no parsing needed for variables/escapes). [S1] - **Readability trade-off** β€” double quotes avoid concatenation clutter when many variables are embedded; single quotes are cleaner for constant strings. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Variable substitution (double): `$x = "John"; echo "Hello $x"; // Hello John`. [S1] - No substitution (single): `$x = "John"; echo 'Hello $x'; // Hello $x`. [S1] - Escape sequence comparison: `echo "Hello $x\n"; echo "\tHow are you?\n";` (double, both work) vs. `echo 'Hello $x\n'; echo '\tHow are you?\n';` (single, literal output including the backslash sequences). [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **μž‘μ€λ”°μ˜΄ν‘œμ˜ λ¦¬ν„°λŸ΄ 좜λ ₯**: $x 같은 λ³€μˆ˜ ꡬ문쑰차 μž‘μ€λ”°μ˜΄ν‘œ μ•ˆμ—μ„œλŠ” κ°’μœΌλ‘œ μΉ˜ν™˜λ˜μ§€ μ•Šκ³  문자 κ·ΈλŒ€λ‘œ 좜λ ₯λœλ‹€λŠ” 점이 예제둜 λͺ…ν™•νžˆ 검증됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” λ³€μˆ˜κ°€ λ§Žμ€ λ¬Έμžμ—΄μ—λŠ” ν°λ”°μ˜΄ν‘œ, μƒμˆ˜ λ¬Έμžμ—΄μ—λŠ” μž‘μ€λ”°μ˜΄ν‘œλ₯Ό μ“°λŠ” 것이 μ‹€μ „ μ½”λ“œ μŠ€νƒ€μΌμ˜ 일반적 관행이닀. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Single quotes output variables literally (PHP): ```php $x = "John"; echo "Hello $x"; // Hello John (double quotes interpolate) echo 'Hello $x'; // Hello $x (single quotes do not) ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[PHP Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[PHP String Functions]], [[PHP String Concatenate]], [[PHP String Escape]] - **μ°Έμ‘° λ§₯락:** λ¬Έμžμ—΄ 기초(λ”°μ˜΄ν‘œ 차이) β€” λ¬Έμžμ—΄ ν•¨μˆ˜ μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” PHP Strings β€” https://www.w3schools.com/php/php_string.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "PHP Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).