PHP - OperatorsWhich of the following is the correct way to concatenate two strings $a and $b in PHP?A$a + $bB$a . $bC$a & $bD$a * $bCheck Answer
Step-by-Step SolutionSolution:Step 1: Identify the concatenation operatorPHP uses the dot (.) operator to join strings, so $a . $b is correct.Step 2: Check other operatorsPlus (+) adds numbers, ampersand (&) is bitwise AND, and asterisk (*) is multiplication.Final Answer:$a . $b -> Option BQuick Check:Dot (.) concatenates strings [OK]Quick Trick: Use dot (.) to join strings, not plus (+) [OK]Common Mistakes:Using + instead of . for stringsUsing & or * operators mistakenlyMissing the dot operator
Master "Operators" in PHP9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PHP Quizzes Arrays - Array sort functions - Quiz 9hard Arrays - Array count and length - Quiz 5medium Conditional Statements - Elseif ladder execution - Quiz 4medium Functions - Default parameter values - Quiz 14medium Loops - Break statement with levels - Quiz 8hard Operators - Operator precedence and evaluation - Quiz 4medium Output and String Handling - Echo vs print behavior - Quiz 15hard Type Handling - Type coercion in operations - Quiz 14medium Variables and Data Types - Float type and precision - Quiz 4medium Variables and Data Types - String type (single vs double quotes) - Quiz 8hard