PHP类不工作"OOP"

ele*_*ail -1 php class

这是我的include.php:

<?php
class cars {
    protected $_car;

    public function __costruct($carName) {
        $this->_car = $carName;

    }

    public function getcarname (){
        return $this->_car;
    }
}?>
Run Code Online (Sandbox Code Playgroud)

这是我的index.php

<?php
require_once 'include.php';

$selling = new cars('Ford');
echo $selling->getcarname();
?>
Run Code Online (Sandbox Code Playgroud)

还是回声没什么!你可以说我是新手上课,但我知道php,处理它有点复杂,而且我发现它不会浪费代码,反正仍然我想学习它,所以我的代码有什么问题?

kba*_*kba 5

你有一个拼写错误,构造函数被调用__construct,而不是__costruct.