创建课程&宾语

时间:2015-02-19 19:02:19

标签: php

我对php有点新鲜,我对Java& C#。通常在C#& Java创建一个我通常会做的类

public class Student { 

public String name;
public int age;

public Student(name, age){
    this.name = name;
    this.age = age;
}


}

我将如何在PHP中执行此操作?

由于

1 个答案:

答案 0 :(得分:2)

您将遇到的差异围绕变量类型(PHP具有任何类型的神奇变量。)其次,构造函数不需要类型:

class Student {
    public $name;
    public $age;

    function __construct($name, $age) {
        $this->name = $name;
        $this->age = $age;
    }
}

$pp = new Student("pp19dd", 123456);