PHP - Variables and Data TypesWhich of the following correctly declares a variable called $city in PHP?Acity = 'New York';B$city = 'New York';C$city := 'New York';Dvar city = 'New York';Check Answer
Step-by-Step SolutionSolution:Step 1: Recall PHP variable syntaxVariables in PHP start with a $ sign followed by the variable name.Step 2: Check each option$city = 'New York'; uses correct syntax with $ and assignment operator =. Options B, C, and D use invalid syntax for PHP.Final Answer:$city = 'New York'; -> Option BQuick Check:PHP variables start with $ [OK]Quick Trick: PHP variables always start with $ [OK]Common Mistakes:Omitting the $ sign before variable nameUsing := instead of = for assignmentUsing JavaScript syntax like var
Master "Variables and Data Types" in PHP9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PHP Quizzes Arrays - Array search functions - Quiz 7medium Arrays - Array access and modification - Quiz 9hard Conditional Statements - Switch statement execution - Quiz 12easy Conditional Statements - Match expression (PHP 8) - Quiz 8hard Conditional Statements - If statement execution flow - Quiz 12easy Functions - Function declaration and calling - Quiz 6medium Loops - Foreach loop for arrays - Quiz 15hard Operators - String concatenation operator - Quiz 9hard PHP Basics and Execution Model - PHP tags and embedding in HTML - Quiz 12easy Type Handling - Type casting syntax - Quiz 8hard