Passing variables on the URL

Can anyone tell me why this isn’t working? I’m in an intro PHP course and this is the example our professor gave us, so I’m not sure what I could possibly be doing wrong.

He gave us this html file:

Preferred Greeting Do you prefer a formal greeting or an informal greeting?

And this PHP file:

<?php $greeting=$_GET['greet']; ?> <?=$greeting ?> World! <?php echo "greeting World!"; ?>

But when I open it and click the links in my browser, it shows the php code, not the actual greeting.

Thanks!

A php file can’t be opened, it has to be run thru a server. The professor didn’t explain how to set up your environment?

Sponsor our Newsletter | Privacy Policy | Terms of Service