Help us understand the problem. What is going on with this article?

phpのclass名は case insensitive という話

More than 1 year has passed since last update.

人のソースを追っていてどうしても宣言が見つからなくて、、、

知らなかった・・・

<?php

class myvar
{
    public static $foo = 1;
}

echo MYVAR::$foo;     // 1

大文字小文字違うclassがあることは知ってたけど、まさか同じとは思わずハマってしまった

Capital letters in class name PHP - Stack Overflow

Classnames in PHP are not case sensitive (that doesn't depend on the operating system)

Linuxでcase insensitiveなら、もう何のOSでも case insensitiveなんじゃなかろうか。

instanceof で調べてわかった

これをやってわかりました

<?php

class myvar
{
    public static $foo = 1;
}

$ins = new myvar();

print_r($ins instanceof myvar); // 1
print_r($ins instanceof MYVAR); // 1

ちなみに

class_alias() っていう落とし穴もあるよ!!

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away