Your code works ok.
Make sure you have saved your page with a .php extension
$assoc = array("first_name"=>"John","last_name"=>"Smith");
<?php echo $assoc["first_name"]; ?>
<?php echo $assoc["first_name"]." ".$assoc["last_name"]; ?>
and make sure your page is going through a server.
If you are testing on your local pc and using windows, you should have something like xampp installed or similar to suit your pc environment.
Note: you will see this if you are opening the page with a normal .html extension which I think is what you may have done.