PHP-Control Flow: Switch-6.All On Your Own


#1

Hello Friends, I am again stuck on control flow, Please point my mistake or offer suggestion.Thanks in advance.


<?php
    $city = moniker;
    switch ($city){
        case "New York":
            echo "Big Apple";
            break;
        case "Paris":
            echo "City of Lights";
            break;
        case "Rome":
            echo "Eternal City";
            break;
        default:
            echo "Your Couch!";
    }
     
    ?>


.


I get this message in output window:

Use of undefined constant moniker - assumed 'moniker' (line 8)Your Couch!

#2

what is moniker?

isn't a string value?
so enclose it in single or double quotes


#3

type $moniker and will run fine :slight_smile:


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.