In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how PHP simulates the response class in asp. It is very detailed and has a certain reference value. Interested friends must read it!
The details are as follows:
People who are used to asp or asp.net developers will often use the response class, which is used to deal with client responses and can achieve jump, output and other functions. There is no such class in php, but it can be simulated by functions.
/ * * Class uses: implement response functions similar to those in asp * / final class Response {private $headers = array (); private $output; private $level = 0; public function addHeader ($key, $value) {$this- > headers [$key] = $value;} public function removeHeader ($key) {if (isset ($this- > headers [$key])) {unset ($this- > headers [$key]) }} public function redirect ($url) {header ('Location:'. $url); exit;} public function setOutput ($output, $level = 0) {$this- > output = $output; $this- > level = $level;} private function compress ($data, $level = 0) {if (isset ($_ SERVER ['HTTP_ACCEPT_ENCODING']) & (strpos ($SERVER [' HTTP_ACCEPT_ENCODING'], 'gzip')! = FALSE)) {$encoding =' gzip' } if (isset ($_ SERVER ['HTTP_ACCEPT_ENCODING']) & & (strpos ($_ SERVER [' HTTP_ACCEPT_ENCODING'], 'Xmuri gzip')! = = FALSE) {$encoding =' x isset gzipmakers;} if (! isset ($encoding)) {return $data;} if (! extension_loaded ('zlib') | | ini_get (' zlib.output_compression')) {return $data } if (headers_sent ()) {return $data;} if (connection_status ()) {return $data;} $this- > addHeader ('Content-Encoding', $encoding); return gzencode ($data, (int) $level);} public function output () {if ($this- > level) {$ouput = $this- > compress ($this- > output, $this- > level);} else {$ouput = $this- > output } if (! headers_sent ()) {foreach ($this- > headers as $key = > $value) {header ($key. ':. $value);}} echo $ouput;}} this is all the content of the article "how PHP simulates response classes in asp". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.