PHP - Output and String HandlingWhy does PHP require the closing identifier of heredoc/nowdoc to be on a new line without indentation or trailing spaces?ATo allow comments inside the stringBTo allow variable parsing inside the stringCTo enable multi-line string supportDTo avoid ambiguity in parsing the string endCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand parsing rulesPHP needs a clear marker to know where the string ends.Step 2: Reason about indentationIf the closing identifier is indented or has trailing spaces, PHP cannot reliably detect the string end.Final Answer:To avoid ambiguity in parsing the string end -> Option DQuick Check:Closing identifier placement = parsing clarity [OK]Quick Trick: Closing identifier must be exact to mark string end [OK]Common Mistakes:Thinking indentation affects variable parsingAssuming multi-line support depends on closing line
Master "Output and String Handling" in PHP9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PHP Quizzes Arrays - Associative array creation - Quiz 6medium Conditional Statements - Match expression (PHP 8) - Quiz 6medium Loops - Nested loop execution - Quiz 7medium Operators - String concatenation operator - Quiz 3easy Operators - Logical operators - Quiz 7medium Operators - Comparison operators (loose and strict) - Quiz 13medium Output and String Handling - Printf and sprintf formatting - Quiz 5medium PHP Basics and Execution Model - PHP tags and embedding in HTML - Quiz 8hard Variables and Data Types - Float type and precision - Quiz 12easy Variables and Data Types - Type juggling in PHP - Quiz 4medium