当前位置: 首页>>代码示例>>PHP>>正文


PHP controller::action方法代码示例

本文整理汇总了PHP中controller::action方法的典型用法代码示例。如果您正苦于以下问题:PHP controller::action方法的具体用法?PHP controller::action怎么用?PHP controller::action使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在controller的用法示例。


在下文中一共展示了controller::action方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * The method finds in the controller directory and runs action, selected
  * in accordance with the incoming parameter.
  * @param type $action
  * @return string
  * @throws Exception
  * @version 14.11.2014
  */
 public static function run($action = "index")
 {
     if (empty($action)) {
         $action = "index";
     }
     // Determine, whether the controller is selected.
     if (empty(self::$controller)) {
         throw new Exception(_("Controller parameter is not set."));
     }
     // For security purposes, we will add additional validation
     // on user input.
     if (!preg_match("/[-_0-9a-z]{2,15}/u", $action)) {
         throw new Exception(_("Controller Action parameter is not valid."));
     }
     self::$action = $action;
     // Define path to the actions of selected controller.
     $SubControllerPath = MODULE_PATH . "controller-" . self::$controller . "/";
     // If Action file is not found - return false. Else - include it.
     if (!is_file($SubControllerPath . $action . ".php")) {
         throw new Exception(_("Controller Action is not found."));
     }
     require_once $SubControllerPath . $action . ".php";
     // Define Contoller Action function name and run it.
     $ActFunction = "controller_" . self::$controller . "_" . $action;
     if (!function_exists($ActFunction)) {
         throw new Exception(_("Controller Action is not found."));
     }
     return $ActFunction();
 }
开发者ID:nongrata-volgmed,项目名称:imcms4,代码行数:37,代码来源:controller.php

示例2: model

<?php

include_once 'controller/controller.php';
$model = new model();
$view = new view();
$controller = new controller($model, $view);
echo $controller->action();
开发者ID:henryroberts,项目名称:ung_dung_mvc,代码行数:7,代码来源:index.php


注:本文中的controller::action方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。