>  기사  >  백엔드 개발  >  php MVC -Command

php MVC -Command

WBOY
WBOY원래의
2016-06-13 10:39:14718검색

php MVC --Command

<?phpabstract class Command {		final function __construct() {	}	function execute(HttpRequest $request) {		$this->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的朋友一定不会陌生

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.