Skip to content

Instantly share code, notes, and snippets.

@blar
blar / realpath1.php
Created January 25, 2016 20:28
realpath ohne strict_types
<?php
declare(strict_types = 0);
$path = 'foobar';
var_dump($path);
$path = realpath($path);
var_dump($path);
<?php
function string_charset_convert($input, $from, $to) {
$output = iconv($from, $to, $string);
if($output === false) {
return $input;
}
return $output;
}
<?php
$array = array(
'foo' => 23,
'bar' => 42,
'foobar' => 1337
);
$order = array('foo', 'foobar', 'bar');
<?php
class User {
/**
* @var DateTimeInterface
*/
private $birthday;
public function setBirthday(DateTimeInterface $birthday) {
<?php
class Foo1 {
private $bar;
public function getBar() {
if(!$this->bar) {
$this->bar = new Bar();
}
<?php
$y = array(
'a',
'c',
'b',
'd'
);
$x = array(
<?php
$pkcs12file = new SplFileInfo(__DIR__.'/passbook.p12');
if(!file_exists($pkcs12file)) {
$pkcs12 = new Pkcs12();
$file = new SplFileInfo(__DIR__.'/passbook_certificate.pem');
$certificate = new Certificate($file);
$pkcs12->setCertificate($certificate);
<?php
class PrivateKey {
}
class Pkcs12 {
public function getPrivateKey() {
@blar
blar / gist:1a9ac456bea9271d1e1d
Created December 7, 2014 13:58
Gefälligkeitszeitpunkt
<?php
$due = new DateTime('2014-12-07 12:22:22');
$diff = $due->diff(new DateTime('now'));
var_dump($diff->format('%H:%M:%s'));
string(8) "02:00:42"
@blar
blar / gist:c351ef96a09b8f20797f
Last active August 29, 2015 14:10
Entwurf zu DOM
<?php
$document = new DomDocument();
$atom = $document->getNamespace('http://www.w3.org/2005/Atom');
$xhtml = $document->getNamespace('http://www.w3.org/1999/xhtml', 'xhtml');
$feed = $atom->createElement('feed');
$document->appendChild($feed);