PHP Basics
Here’s the most basic thing you can do in PHP, print something on the browser screen. The command for doing this is print. So the command to print “hello” is
print “hello”;
with a semicolon at the end. Put this between some PHP markers <?php to start and ?> to end, and you have a php program.
<?php print “Hello”; ?>
You can do it other ways, like putting the word in brackets
<?php print(“Hello”); ?>
and it won’t change the output. you can leave out the semicolon since this is the only statement
<?php print “look, no semicolon” ?>
and you can squish the last php marker really close to the quotes
<?php print “it’s really close!”?>
but you can’t do this
<?phpprint “too close for comfort” ?>
bizarrely, you can do away with the quotes and just use brackets
<?php print(even_this_prints) ?>
and it will still work, but this won’t
<?php print(no spaces please) ?>