doushenjia8514 2017-01-23 02:55
浏览 34

SLIM 3:PHP变量

im using slim for the first time and want to know why i get undefined in $file variable. Do i have to add the variables to the container or how it works? How the cycle works?, neither work if i add var_dump inside the get.

In another area of the site i use define, but i think it´s not the best way.

Hope you can help.

$app->get('/path/{id}-{title}', function ($request, $response, $args) {

switch ($args['id']) {
    case '1':
        $file = 'pathtofile';
        break;
    case '2':
        $file = 'pathtofile2';
        break;
}

var_dump($args);

return $this->view->render($response, $file.'.html', [
    'id' => $args['id'],
    'title' => $args['title']
]);
})->setName('path');

Thanks

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 有赏,i卡绘世画不出
    • ¥15 如何用stata画出文献中常见的安慰剂检验图
    • ¥15 c语言链表结构体数据插入
    • ¥40 使用MATLAB解答线性代数问题
    • ¥15 COCOS的问题COCOS的问题
    • ¥15 FPGA-SRIO初始化失败
    • ¥15 MapReduce实现倒排索引失败
    • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
    • ¥15 找一位技术过硬的游戏pj程序员
    • ¥15 matlab生成电测深三层曲线模型代码