欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php MVC -Command

程序员文章站 2022-06-17 18:02:45
...
php MVC --Command
doExecute($request);
	}

	abstract function doExecute(HttpRequest $request) ;
}


public class HttpRequest {
	
	private $properties;

	private $feedback = array();
	
	function __construct() {
		$this->init();
	}

	
	function init() {
		if (isset($_SERVER['REQUEST_METHOD'])) {
			$this->properties = $_REQUEST;
			return;
		}

		foreach($_SERVER['argv'] as $arg) {
			if (strpos($arg,'=')) {
				list($key,$val) = explode("=", $arg);
				$this->setProperty($key,$val);
			}
		}
	}

	function getProperty($key) {
		if (isset($this->properties[$key])) {
			return $this->properties[$key];
		}
	}

	function setProperty($key,$val) {
		$this->properties[$key] = $val;
	}

	function addFeedback($msg) {
		array_push($this->feedback, $msg);
	}

	function getFeedback() {
		return this->feedback;
	}

	function getFeedbackString($separator = "\n") {
		return implode( $separator,$this->feedback) ;
	}

}
?>

?最近在看php设计模式,看到例子不错,顺便做下记录吧,熟悉struts1.x的朋友一定不会陌生

php MVC -Command

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频