Skip to content

Instantly share code, notes, and snippets.

View Najaf's full-sized avatar

Ali Najaf

View GitHub Profile
<?php
class Song {
private $duration;
private $name;
//Getters/Setters
function setName( $name ) {
return $this->name;
}
<?php
$address = array(
'name' => 'John Smith',
'line1' => '1 Somewhere Road',
'line2' => 'Happytown',
'region' => 'Somewhere County',
'country' => 'United Kingstates'
'postcode' => '123 ABC'
);
<?php
$address = new Address();
$address->name = 'John Smith';
$address->line2 = ... etc
(1..100).each do |i|
print "Fizz" if i % 3 == 0
print "Buzz" if i % 5 == 0
print i.to_s unless i % 3 == 0 or i % 5 == 0
print "\n"
end
<?php
function render($page, $params = array()) {
extract($params);
include "{$page}.php";
}
<!DOCTYPE html>
<html>
<head>
<link rel='stylesheet' type='text/css' href='style.css' media='screen' />
<script type='text/javascript' src='jquery.js'></script>
<title>Alis Fruity Milkshakes</title>
</head>
<body>
<div id='wrapper'>
<div id='header'>
<h3><?= $title ?></h3>
<div id='content'>
<?= $content ?>
</div>
<?php
function render_page($page, $params = array(), $layout = 'layout') {
extract($params);
$__page = "{$page}.php";
include "{$layout}.php";
}
<?php
//calling this with the above files (layout.php + page.php) in the working directory
render_page('page', array(
'title' => "About The Shakes",
'content' => "<p>Bringing the boys to the yard since 1976</p>"
));
//would then render this =>
@Najaf
Najaf / sidebar.html
Created October 16, 2010 12:50
Test gist
<ul>
<li>
<a href='/home.php'>Home</a>
</li>
<li>
<a href='/about.php'>About</a>
</li>
<li>
<a href='/contact.php'>Contact</a>
</li>