Skip to content

Instantly share code, notes, and snippets.

@robynitp
Last active November 17, 2022 03:17
Show Gist options
  • Save robynitp/8924077 to your computer and use it in GitHub Desktop.
Save robynitp/8924077 to your computer and use it in GitHub Desktop.
Intro to PHP with HTML
<html>
<head>
<title>The Top Bar Title</title>
</head>
<body>
<p>Some information</p>
<!-- We're about to start PHP -->
<? php // We're in PHP now.
// assign some variables -- variables in PHP start with a dollar sign ($)
$user_name = "Jennifer";
$user_address = "721 Broadway";
// end PHP (for now)
?>
<!-- Now we're back in HTML -->
<h1>User Profile</h1>
<p><strong>Name</strong><br/>
<?php
// We're back in PHP now
echo $user_name; // output a variable
echo '</p>'; // end the paragraph tag started above
// Output some HTML and PHP all together
echo "<p><strong>Address</strong><br/>$user_address</p>";
// end PHP
?>
<!-- Back in HMTL -->
<div id="footer">
<p>Follow us on Twitter!</p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment