--- id: php-variables title: "PHP Variables" 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", "variables"] raw_sources: ["https://www.w3schools.com/php/php_variables.asp"] applied_in: [] github_commit: "" --- # [[PHP Variables]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) PHP has NO variable declaration command β€” a variable is created the instant you assign it a value (`$x = 5;`), unlike statically-declared languages; this is the source's explicit framing of what makes PHP "loosely typed" from the very first line of variable usage. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`$` prefix** β€” every variable name starts with `$`. [S1] - **Naming rules** β€” starts with a letter or underscore (never a number); alphanumeric + underscore only; case-sensitive. [S1] - **No declaration keyword** β€” a variable springs into existence at first assignment. [S1] - **Loosely typed** β€” PHP infers the data type from the assigned value; no explicit type annotation needed. [S1] - **`var_dump()`** β€” reveals both the data type and value of a variable. [S1] - **Multiple assignment** β€” `$x = $y = $z = "Fruit";` assigns the same value to several variables in one statement. [S1] - **Supported data types** β€” string, int, float, bool, array, object, null, resource, mixed. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Basic assignment: `$x = 5; $y = "John";`. [S1] - Output with interpolation: `$txt = "W3Schools.com"; echo "I love $txt!";` β€” equivalent to `echo 'I love ' . $txt . '!';`. [S1] - Type inspection: `var_dump(5); var_dump("John"); var_dump(3.14); var_dump(true); var_dump([2, 3, 56]); var_dump(NULL);`. [S1] - Multi-assignment: `$x = $y = $z = "Fruit";`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” var_dump()둜 λ³€μˆ˜μ˜ μ‹€μ œ νƒ€μž…κ³Ό 값을 ν™•μΈν•˜λŠ” 것이 λ””λ²„κΉ…μ˜ ν‘œμ€€ 도ꡬ닀. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Multi-variable assignment in one line (PHP): ```php $x = $y = $z = "Fruit"; ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[PHP Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[PHP Variables Scope]], [[PHP Echo Print]], [[PHP Data Types]] - **μ°Έμ‘° λ§₯락:** λ³€μˆ˜ 기초 문법 β€” μŠ€μ½”ν”„(Scope)/데이터 νƒ€μž… μ±•ν„°λ‘œ ν™•μž₯. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” PHP Variables β€” https://www.w3schools.com/php/php_variables.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "PHP Variables" page (Astra wiki-curation, P-Reinforce v3.1 format).