Skip to content

Instantly share code, notes, and snippets.

@christeredvartsen
Created July 5, 2011 19:48
Show Gist options
  • Save christeredvartsen/1065728 to your computer and use it in GitHub Desktop.
Save christeredvartsen/1065728 to your computer and use it in GitHub Desktop.
PHP class visibility
<?php
class article {
private $title;
public function __construct($title) {
$this->title = $title;
}
protected function getTitle() {
return $this->title;
}
}
class articleproxy extends article {
private $article;
public function __construct(article $article) {
$this->article = $article;
}
public function getTitle() {
return strtolower($this->article->getTitle());
}
}
$article = new article('SOME TITLE');
$articleproxy = new articleproxy($article);
print($articleproxy->getTitle());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment