8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPにルートクラスなんて無かった

Last updated at Posted at 2014-05-25

Java

ソースコード
public class Main {
    public static void main(String[] args) {
        new A();
        new B();
    }
}
 
class A {
    public A() {
        System.out.println(getClass().getSuperclass().getSimpleName());
    }
}
 
class B extends Object {
    public B() {
        System.out.println(getClass().getSuperclass().getSimpleName());
    }
}
実行結果
Object
Object

C#

ソースコード
class Program
{
    static void Main(string[] args)
    {
        new A();
        new B();
    }
}
 
class A
{
    public A()
    {
        System.Console.WriteLine(this.GetType().BaseType.Name);
    }
}
 
class B : object
{
    public B()
    {
        System.Console.WriteLine(this.GetType().BaseType.Name);
    }
}
実行結果
Object
Object

PHP

ソースコード
<?php

new A;
new B;
 
class A {
    public function __construct() {
        var_dump(get_parent_class());
    }
}
 
class B extends stdClass {
    public function __construct() {
        var_dump(get_parent_class());
    }
}
実行結果
bool(false)
string(8) "stdClass"

何か false じゃfu*k

8
8
7

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?