誰かがガイドを持っているか、クラスを設定してクラスからindex.phpにデータを渡す方法の簡単な例を教えてくれますか?
フレームワークのようにできると思っていたのですが、できませんか?
$this->class->function();
クールクラス.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.php:
Include('Foo.php');
$my_Foo = Foo();
$my_Foo->doSomething();
ここで何が起こっているかについてはかなり簡単だと思います...だから、それはそのままにしておいてください。あまり譲りたくない。