设置PHP类';s没有框架


Setting Up PHP Class's without a framework

有人有指南吗?或者可以为我提供一个如何设置类并将数据从类传递到index.php的快速示例吗?

我在想我可以像在框架中那样做,不是吗?

$this->class->function();

coolclass.php

class coolClass
{
    public function getPrintables()
    {
        return "hello world!";
    }
}

index.php

include 'coolclass.php';
$instance = new coolClass();
echo $instance->getPrintables();

一个快速示例:

Foo.php

class Foo {
  public __construct() {
    ..initialize your variables here...
  }
  public function doSomething() {
    ..have your function do something...
  }
}

Index.hp:

Include('Foo.php');
$my_Foo = Foo();
$my_Foo->doSomething();

我认为这里发生的事情很直接。。。我就这样算了。不想泄露太多信息。