Skip to content

Instantly share code, notes, and snippets.

View shin1x1's full-sized avatar
😀

Masashi Shinbara shin1x1

😀
View GitHub Profile
@shin1x1
shin1x1 / add.php
Created March 17, 2015 06:19
PHP 7 code
<?php
declare(strict_types=1);
function add(int $x, int $y): int {
return $x + $y;
}
echo add(1, 2) . PHP_EOL;
<?php
ClassLoader::addDirectories(
array(
app_path() . '/commands',
app_path() . '/controllers',
app_path() . '/controllers/admin', // <--- added
app_path() . '/models',
app_path() . '/database/seeds',
create table users (
id serial primary key,
username text not null,
password text not null,
created timestamp
);
INSERT INTO users (username, password, created) VALUES('osaka', '', NOW());
INSERT INTO users (username, password, created) VALUES('kyoto', '', NOW());
INSERT INTO users (username, password, created) VALUES('hyogo', '', NOW());
<?php
class A {
public $v = 1;
public function func() {
call_user_func(array($this, 'some'));
}
public function some() {
echo $this->v;
}
<?php
// authentication
if (!authentication()) {
exit;
}
$filepath = "/path/to/file";
$sizes = getimagesize($filepath);
if (!empty($sizes['mime'])) {
<?php
// authentication
if (!authentication()) {
exit;
}
$filepath = "/path/to/file";
$sizes = getimagesize($filepath);
if (!empty($sizes['mime'])) {
<?php
class Foo {
public $value = 'abc';
public function __wakeup() {
echo(__LINE__.' '.__METHOD__).PHP_EOL;
}
public function __destruct() {
echo(__LINE__.' '.__METHOD__).PHP_EOL;
<?php
class Foo {
public $value = 'abc';
public function __toString() {
echo(__METHOD__).PHP_EOL;
return '';
}
}
<?php
class Foo {
public $value = 'abc';
public function __destruct() {
echo(__METHOD__).PHP_EOL;
}
}
function func($text) {