Heim  >  Artikel  >  Backend-Entwicklung  >  php MVC -Command

php MVC -Command

WBOY
WBOYOriginal
2016-06-13 10:39:14714Durchsuche

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的朋友一定不会陌生

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:从一路php面试题说起Nächster Artikel:PHP验证码效能的实现