Skip to content

Instantly share code, notes, and snippets.

@takeokunn
Last active September 24, 2022 05:13
Show Gist options
  • Save takeokunn/b8d8abd00a8cdbbd3c8c4b706db5c002 to your computer and use it in GitHub Desktop.
Save takeokunn/b8d8abd00a8cdbbd3c8c4b706db5c002 to your computer and use it in GitHub Desktop.

GMO

Q3

var_dump(
    str_replace(['suzuri', 'minne'], ['lolipop', 'colorme'], 'lolipop-colorme-suzuri-minne')
);
string(31) "lolipop-colorme-lolipop-colorme"

Q4

$var = '0';
var_dump(isset($var));

$var = '0';
var_dump(empty($var));

$var = '0';
var_dump(is_null($var));
bool(true)
bool(true)
bool(false)

Q5

$array = [
    "0" => "a",
    " 0"=> "b",
    "01" => "c",
    null => "d",
    "e",
    true => "f",
    false => "g",
];

$number = count(array_keys($array));

var_dump($number);
int(5)

Q6

class A {
    public static function hoge(): string {
        return '4';
    }
}

class B extends A {
    public static function hoge(): string {
        return '9';
    }

    public static function test(): string {
        return static::hoge() . parent::hoge() . self::hoge();
    }
}

class C extends B {
    public static function hoge(): string {
        return '94';
    }
}

echo C::test() . PHP_EOL;
9449

Q7

$keys = ['G','M','O',1,'N','T','E','R','N','E','T'];
function strSort($a, $b) {
    return $a < $b ? -1 : 1;
};
usort($keys, 'strSort');

var_dump(implode($keys));
string(11) "1EEGMNNORTT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment