Skip to content

Instantly share code, notes, and snippets.

@greypants
Forked from jgarber623/_layout.php
Created March 4, 2013 21:53
Show Gist options
  • Save greypants/5086024 to your computer and use it in GitHub Desktop.
Save greypants/5086024 to your computer and use it in GitHub Desktop.
PHP: Rails Layout
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?php echo $page_title; ?></title>
</head>
<body>
<?php echo $content_for_layout; ?>
</body>
</html>
<?php
$page_title = 'Welcome to my website!';
ob_start();
?>
<h1>Welcome to my website!</h1>
<p>It's created using PHP's output buffering control.</p>
<?php
$content_for_layout = ob_get_clean();
require_once( '_layout.php' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment