Skip to content

Instantly share code, notes, and snippets.

View lloc's full-sized avatar
🏠
Working from home

Dennis Ploetner lloc

🏠
Working from home
View GitHub Profile
<?php
/**
* Class BoundingBox
*/
class BoundingBox {
/**
* @var float $lat
* @var float $lon
<?php
namespace wctrn\realloc;
abstract class Option {
abstract function get( int $id );
}
<?php
namespace wctrn\realloc;
interface Thing {
public function the_content( string $content ) : void;
}
class Tag implements Thing {
<?php
try {
// Something throws an Exception or Error.
} catch ( Throwable $t ) {
// will match only in PHP 7
} catch ( Exception $e ) {
// will be reached in PHP 5
}
<?php
namespace wctrn\realloc;
require_once 'late-static-bindings-post.php';
class Page extends Post {
public function get_content() {
return 'Hello Turin!';
<?php
namespace wctrn\realloc;
class Post {
public static function init() {
return new static();
}
<?php
namespace wctrn\realloc;
class Post {
protected $content;
public function get_content() : string {
return $this->content;
<?php
namespace wctrn\realloc;
class Post {
protected $content;
public function set_content( string $content ) {
$this->content = $content;
<?php
namespace wctrn\realloc;
class Post {
public function get_content() {
return 'Hello World!';
}
}
<?php
require_once 'namespace-class.php';
// Namespace: Using
echo ( new \wctrn\realloc\Post() )->get_content(), PHP_EOL;
// Namespaces: Importing
use \wctrn\realloc\Post;
echo ( new Post() )->get_content(), PHP_EOL;