繁体   English   中英

调用.class.php文件形式的方法(超薄框架)

[英]Calling a method form a .class.php file (slim framework)

我正在使用Slim框架开发Web应用程序。 但是,我遇到了一些我无法解决的问题。

我想在类中组织代码并从类中调用某些方法。 我有一个index.php文件,其中存在以下功能:

$app->post('/',  function () use ($app) {
// some code here
//a variable  $result I want to get the result from a method of the    class Generate_num
$result = (here I want it to take as a result the function "generate"     from a .class.php file which I have stored in a special folder "classes"
 //another code
});

我的班级代码看起来像这样

class Generate_num
{
public static function generate()
 {
//some code
 }
}

有什么建议么 ? 谢谢 !

给定此类:

class Generate_num
{
    public static function generate()
    {
        //some code that creates $number
        return $number;
    }
}

您这样称呼它:

$number = Generate_num::generate();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM