php 清除换行符,清除制表符,去掉注释标记总结

 更新时间:2016年11月25日 15:49  点击:1328
本文章总结了几种利用php 清除换行符,清除制表符,去掉注释标记实现代码,有需要的朋友可参考本文章。
 代码如下 复制代码

<?php
 /**
  * 压缩html : 清除换行符,清除制表符,去掉注释标记  
  * @param   $string  
  * @return  压缩后的$string 
  * */
 function compress_html($string) {  
     $string = str_replace("rn", '', $string); //清除换行符  
     $string = str_replace("n", '', $string); //清除换行符  
     $string = str_replace("t", '', $string); //清除制表符  
     $pattern = array (  
                     "/> *([^ ]*) *</", //去掉注释标记  
                     "/[s]+/",  
                     "/<!--[^!]*-->/",  
                     "/" /",  
                     "/ "/",  
                     "'/*[^*]**/'" 
                     );  
     $replace = array (  
                     ">\1<",  
                     " ",  
                     "",  
                     """,  
                     """,  
                     "" 
                     );  
     return preg_replace($pattern, $replace, $string);  
 }

去除连续的空格和换行符

 代码如下 复制代码

<?php
$str="i   am    a     booknnnnnmoth";
//去除所有的空格和换行符
echo preg_replace("/[s]{2,}/","",$str).'<br>';
//去除多余的空格和换行符,只保留一个
echo preg_replace("/([s]{2,})/","\1",$str);
?>

去除回车换行符

preg_replace("'([rn])[s]+'", "", $content) //去除回车换行符

 代码如下 复制代码

<?php
// $document 应包含一个 HTML 文档。
// 本例将去掉 HTML 标记,javascript 代码
// 和空白字符。还会将一些通用的
// HTML 实体转换成相应的文本。

$search = array ("'<script[^>]*?>.*?</script>'si",  // 去掉 javascript
                 "'<[/!]*?[^<>]*?>'si",           // 去掉 HTML 标记
                 "'([rn])[s]+'",                 // 去掉空白字符
                 "'&(quot|#34);'i",                 // 替换 HTML 实体
                 "'&(amp|#38);'i",
                 "'&(lt|#60);'i",
                 "'&(gt|#62);'i",
                 "'&(nbsp|#160);'i",
                 "'&(iexcl|#161);'i",
                 "'&(cent|#162);'i",
                 "'&(pound|#163);'i",
                 "'&(copy|#169);'i",
                 "'&#(d+);'e");                    // 作为 PHP 代码运行

$replace = array ("",
                  "",
                  "\1",
                  """,
                  "&",
                  "<",
                  ">",
                  " ",
                  chr(161),
                  chr(162),
                  chr(163),
                  chr(169),
                  "chr(\1)");

$text = preg_replace ($search, $replace, $document);
?>

下面总结了三种缓存文件方法,一种是nginx下的缓存fastcgi_cache和proxy_cache,一种利用memcache缓存,另一种是利用php文件缓存哦。

nginx有两种缓存机制:fastcgi_cache和proxy_cache
下面我们来说说这两种缓存机制的区别吧
proxy_cache作用是缓存后端服务器的内容,可能是任何内容,包括静态的和动态的
fastcgi_cache作用是缓存fastcgi生成的内容,很多情况是php生成的动态内容
proxy_cache缓存减少了nginx与后端通信的次数,节省了传输时间和后端带宽
fastcgi_cache缓存减少了nginx与php的通信次数,更减轻了php和数据库的压力。
 
proxy_cache缓存设置
#注:proxy_temp_path和proxy_cache_path指定的路径必须在同一分区
proxy_temp_path   /data0/proxy_temp_dir;
#设置Web缓存区名称为cache_one,内存缓存空间大小为200MB,1天没有被访问的内容自动清除,硬盘缓存空间大小为30GB。
proxy_cache_path  /data0/proxy_cache_dir  levels=1:2   keys_zone=cache_one:200m inactive=1d max_size=30g;
 

 代码如下 复制代码

server
  {
    listen       80;
    server_name  www.yourdomain.com 192.168.8.42;
    index index.html index.htm;
    root  /data0/htdocs/www; 

    location /
    {
         #如果后端的服务器返回502、504、执行超时等错误,自动将请求转发到upstream负载均衡池中的另一台服务器,实现故障转移。
         proxy_next_upstream http_502 http_504 error timeout invalid_header;
         proxy_cache cache_one;
         #对不同的HTTP状态码设置不同的缓存时间
         proxy_cache_valid  200 304 12h;
         #以域名、URI、参数组合成Web缓存的Key值,Nginx根据Key值哈希,存储缓存内容到二级缓存目录内
         proxy_cache_key $host$uri$is_args$args;
         proxy_set_header Host  $host;
         proxy_set_header X-Forwarded-For  $remote_addr;
         proxy_pass http://backend_server;
         expires      1d;
    }
   
    #用于清除缓存,假设一个URL为http://192.168.8.42/test.txt,通过访问http://192.168.8.42/purge/test.txt就可以清除该URL的缓存。
    location ~ /purge(/.*)
    {
     #设置只允许指定的IP或IP段才可以清除URL缓存。
     allow            127.0.0.1;
     allow            192.168.0.0/16;
     deny            all;
     proxy_cache_purge    cache_one   $host$1$is_args$args;
    }   

    #扩展名以.php、.jsp、.cgi结尾的动态应用程序不缓存。
    location ~ .*.(php|jsp|cgi)?$
    {
         proxy_set_header Host  $host;
         proxy_set_header X-Forwarded-For  $remote_addr;
         proxy_pass http://backend_server;
    }

    access_log  off;
  }
}
 


fastcgi_cache缓存设置
#定义缓存存放的文件夹

 代码如下 复制代码
fastcgi_cache_path   /tt/cache  levels=1:2 keys_zone=NAME:2880m inactive=2d max_size=10G;

#定义缓存不同的url请求

 代码如下 复制代码
fastcgi_cache_key "$scheme$request_method$host$uri$arg_filename$arg_x$arg_y";
 
server {
        listen       8080;
        server_name  www.example .com;
        location / {
            root   /www;
            index  index.html index.htm index.php;
        }
 
        location ~ (|.php)$ {
            root           /www;
            fastcgi_pass   127.0.0.1:9000;
           
            fastcgi_cache   NAME;
            fastcgi_cache_valid 200 48h;
            fastcgi_cache_min_uses  1;
            fastcgi_cache_use_stale error  timeout invalid_header http_500;
           
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
            #设置缓存的过程中发现无法获取cookie,经查需要定义这句话
            fastcgi_pass_header Set-Cookie;
        }
 
        log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
              '$status $body_bytes_sent "$http_referer" '
              '"$http_user_agent" $http_x_forwarded_for';
access_log  /httplogs/access.log  access;
}

总的来说  nginx的proxy_cache和fastcgi_cache的缓存配置差不多。

--------------------------------------------------------------------------------

memcache缓存
在讨论memcache缓存之前,我们先了解下mysql的内存缓存吧
mysql的内存缓存可以在my.cnf中指定大小:内存表和临时表不同,临时表也是存放内存中,临时表最大的内存需要通过tmp_table_size=128M设定。当数据查过临时表的最大值设定时,自动转为磁盘表,此时因需要进行IO操作,性能会大大下降,而内存表不会,内存满了后,会提示数据满错误。
例:

 代码如下 复制代码
create table test
(
    id int unsigned not null auto_increment primary key
    state char(10),
    type char(20),
    date char(30)
)engine=memory default charset=utf8

内存表的特性:
1.内存表的表定义存放在磁盘上,扩展名为.frm,所以重启不会丢失
2.内存表的数据是存放在内存中,重启会丢失数据
3.内存表使用一个固定的长度格式
4.内存表不支持blob或text列,比如varchar与text字段就不会被支持
5.内存表支持auto_increment列和对可包含null值的列的索引
6.内存表不支持事物
7.内存表是表锁,当修改频繁时,性能可能会下降

分享一个存php缓存类

 代码如下 复制代码

<?php

class Cache
{

    private static $_instance;
    protected $_cacheId = null;

    const CLEANING_MODE_ALL  = 'all';
    const CLEANING_MODE_OLD = 'old';

    protected $_options = array(
        'cache_dir' => null,                  //数据缓存目录
        'life_time' => 7200,                  //缓存时间
        'page_dir' => null,                   //文本缓存目录
        'cache_prefix' => 'cache_'        //缓存前缀
    );

    private function __construct(){}
  
    //创建__clone方法防止对象被复制克隆
    private function __clone(){}
  
    /**
     * 取缓存对象,如果存在直接返回,如果不存在实例化本身
     * @return object cache
     */
    public static function getInstance(){
      
        if(! self::$_instance){
      
            self::$_instance = new self();
        }
      
        return self::$_instance;
    }
      
    /**
     * 设置缓存参数集
     * @param array $options 要设置的缓存参数集
     */
    public function setOptions($options = array()){
  
        while (list($name, $value) = each($options)) {
            $this->setOption($name, $value);
        }
    }
  
    /**
     * 取得当前缓存参数,如果$name为空返回全部参数,否则返回该参数值
     * @param string $name 要返回的参数名称
     * @return string or array $option;
     */
    public function getOption($name = null){
  
        if(null === $name)
            return $this->_options;
  
        if (!is_string($name)) {
            throwException("不正确的参数名称 : $name");
        }
      
        if (array_key_exists($name, $this->_options)){
            return $this->_options[$name];
        }
    }
  
    /**
     * 设置缓存参数
     * @param array $options 要设置的缓存参数
     */
    protected function setOption($name, $value){
  
        if (!is_string($name)) {
            throwException("不正确的参数名称 : $name");
        }
        $name = strtolower($name);
        if (array_key_exists($name, $this->getOption())){
            $this->_options[$name] = $value;
        }
      
        if ($this->_options['cache_dir'] === null) {
            $this->setOption('cache_dir', $this->getTmpDir() . DIRECTORY_SEPARATOR);
        }
      
        if ($this->_options['page_dir'] === null) {
            $this->setOption('page_dir', $this->getTmpDir() . DIRECTORY_SEPARATOR);
        }
    }
  
    /**
     * 读取数据缓存,如果不存在或过期,返回false
     * @param string $id 缓存ID
     * @return false or data
     */
    public function load($id){

        $this->_cacheId = $id;      
        $file = $this->getOption('cache_dir') . $this->getOption('cache_prefix') . $this->_cacheId;
              
        if (@filemtime($file) >= time()){
      
            return unserialize(file_get_contents($file));
        } else {
            @unlink($file);
            return false;
        }
    }
  
    /**
     * 保存数据缓存,并设置缓存过期时间
     * @param array or string $data 要缓存的数据
     * @param int $lifeTime 缓存过期时间
     */
    public function save($data, $lifeTime = null){
  
        if(null !== $lifeTime)
            $this->setOption('life_time', $lifeTime);
  
        $file = $this->getOption('cache_dir') . $this->getOption('cache_prefix') . $this->_cacheId;
        $data = serialize($data);
        @file_put_contents($file, $data);
        @chmod($file, 0777);
        @touch($file, time() + $this->getOption('life_time']));
    }  
  
    /**
     * 读取输出缓存,如果不存在或缓存过期将重新开启输出缓存
     * @param string $id 缓存ID
     */
    public function start($id){

        $this->_cacheId = $id;
        $file = $this->getOption('page_dir') . $this->getOption('cache_prefix') . $this->_cacheId;
              
        if (@filemtime($file) >= time()){
      
            return file_get_contents($file);
        } else {
            @unlink($file);
            ob_start();
            return false;
        }
    }

    /**
     * 删除指定ID缓存
     * @param string $id 缓存ID
     */
    public function remove($id){

        $this->_cacheId = $id;
        //删除附合条件的数据缓存
        $file = $this->getOption('cache_dir') . $this->getOption('cache_prefix') . $this->_cacheId;
        @unlink($file);
        //删除附合条件的输出缓存
        $file = $this->getOption('page_dir') . $this->getOption('cache_prefix') . $this->_cacheId;
        @unlink($file);
    }
  
    /**
     * 保存输出缓存,并设置缓存过期时间
     * @param int $lifeTime 缓存过期时间
     */
    public function end($lifeTime = null){

        if(null !== $lifeTime)
            $this->setOption('life_time', $lifeTime);
  
        $file = $this->getOption('page_dir') . $this->getOption('cache_prefix') . $this->_cacheId;
        $data = ob_get_contents();
        ob_end_clean();
        @file_put_contents($file, $data);
        @chmod($file, 0777);
        @touch($file, time() + $this->getOption('life_time']));
    }
  
    /**
     * 根据参数清除相应缓存
     * @param string $mode 缓存类型,包括(CLEANING_MODE_ALL:所有缓存, CLEANING_MODE_OLD: 过期缓存)
     */
    public function clear($mode = CLEANING_MODE_OLD){
  
        $dirs = array('cache_dir', 'page_dir');
        foreach($dirs as $value){
            if(null != $this->getOption($value)){
                $files = scandir($this->getOption($value));
                switch ($mode) {

                    case CLEANING_MODE_ALL:
                    default:
                        foreach ($files as $val){
                            @unlink($this->getOption($value) . $val);
                        }
                        break;

                    case CLEANING_MODE_OLD:
                    default:
                        foreach ($files as $val){
                            if (filemtime($this->getOption($value) . $val) < time()){
                                @unlink($this->getOption($value) . $val);
                            }
                        }
                        break;
                }
            }
        }
    }
  
    /**
     * 取临时文件夹为缓存文件夹
     * @return $dir 临时文件夹路径
     */
    public function getTmpDir(){
  
        $tmpdir = array();
        foreach (array($_ENV, $_SERVER) as $tab) {
            foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
                if (isset($tab[$key])) {
                    if (($key == 'windir') or ($key == 'SystemRoot')) {
                        $dir = realpath($tab[$key] . '\temp');
                    } else {
                        $dir = realpath($tab[$key]);
                    }
                    if ($this->_isGoodTmpDir($dir)) {
                        return $dir;
                    }
                }
            }
        }
        $upload = ini_get('upload_tmp_dir');
        if ($upload) {
            $dir = realpath($upload);
            if ($this->_isGoodTmpDir($dir)) {
                return $dir;
            }
        }
        if (function_exists('sys_get_temp_dir')) {
            $dir = sys_get_temp_dir();
            if ($this->_isGoodTmpDir($dir)) {
                return $dir;
            }
        }
        //通过尝试创建一个临时文件来检测
        $tempFile = tempnam(md5(uniqid(rand(), TRUE)), '');
        if ($tempFile) {
            $dir = realpath(dirname($tempFile));
            unlink($tempFile);
            if ($this->_isGoodTmpDir($dir)) {
                return $dir;
            }
        }
        if ($this->_isGoodTmpDir('/tmp')) {
            return '/tmp';
        }
        if ($this->_isGoodTmpDir('\temp')) {
            return '\temp';
        }
        throw new Exception('无法确定临时目录,请手动指定cache_dir', E_USER_ERROR);
    }

    /**
     * 验证给定的临时目录是可读和可写的
     *
     * @param string $dir 临时文件夹路径
     * @return boolean true or false 临时文件夹路径是否可读写
     */
    protected function _isGoodTmpDir($dir){
  
        if (is_readable($dir)) {
            if (is_writable($dir)) {
                return true;
            }
        }
        return false;
    }


}//endclass

下面我人利用union all来替换in或or,有需要的朋友可参考一下。

使用or:

 代码如下 复制代码
WHERE * FROM article
WHERE article_category=2
OR article_category=3
ORDER BY article_id DESC
LIMIT 5
// 执行时间:11.0777

 
使用in:

 代码如下 复制代码

SELECT * FROM article
WHERE article_category IN (2,3)
ORDER BY article_id DESC
LIMIT 5

// 执行时间:11.2850
使用union all:

 代码如下 复制代码

(
    SELECT * FROM article
    WHERE article_category=2
    ORDER BY article_id DESC
    LIMIT 5
) UNION ALL (
    SELECT * FROM article
    WHERE article_category=3
    ORDER BY article_id DESC
    LIMIT 5
)
ORDER BY article_id DESC
LIMIT 5
// 执行时间:0.0261

下面我们来介绍一下关于php实现断点续传的代码,有需要学习的朋友可参考一下。

让PHP下载代码支持断点续传 主要靠的 HTTP协议中header Content-Range来实现
先来说说 HTTP的下载原理
对于HTTP协议,向服务器请求某个文件时,只要发送类似如下的请求即可:

 代码如下 复制代码

GET /Path/FileName HTTP/1.0
Host: www.server.com:80

Accept: **表示接收任何类型的数据。User-Agent表示用户代理,这个字段可有可无,但强烈建议加上,因为它是服务器统计、追踪以及识别客户端的依据。Connection字段中的close表示使用非持久连接。
关于HTTP协议更多的细节可以参考RFC2616(HTTP 1.1)。因为我只是想通过HTTP协议实现文件下载,所以也只看了一部分,并没有看全。
如果服务器成功收到该请求,并且没有出现任何错误,则会返回类似下面的数据:

 代码如下 复制代码
HTTP/1.0 200 OK
Content-Length: 13057672
Content-Type: application/octet-stream
Last-Modified: Wed, 10 Oct 2005 00:56:34 GMT
Accept-Ranges: bytes
ETag: "2f38a6cac7cec51:160c"
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Wed, 16 Nov 2005 01:57:54 GMT
Connection: close


先定义一个函数 getRange() 这个函数用来处理 header中 Range 具体数据的处理

 代码如下 复制代码
/** $file_size  文件大小 */
 function getRange($file_size){
    $range = isset($_SERVER['HTTP_RANGE'])?$_SERVER['HTTP_RANGE']:null;
    if(!empty($range)){
        $range = preg_replace('/[s|,].*/', '', $range);
        $range = explode('-',substr($range,6));
        if (count($range) < 2 ) {
            $range[1] = $file_size;
        }
        $range = array_combine(array('start','end'),$range);
        if (empty($range['start'])) {
            $range['start'] = 0;
        }
        if (!isset ($range['end']) || empty($range['end'])) {
            $range['end'] = $file_size;
        }
        return $range;
    }
    return null;
}

假设文件的地址为 $file_path

 代码如下 复制代码

$speed = 512;//此参数为下载最大速度
$pos = strrpos($file_path, "/");
$file_name = substr($file_path, $pos+1);
$file_size = filesize($file_path);
$ranges = getRange($file_size);
$fh =  fopen($file_path, "rb");
header('Cache-control: public');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$file_name);
if ($ranges != null) {
    header('HTTP/1.1 206 Partial Content');
    header('Accept-Ranges: bytes');
    header(sprintf('Content-Length: %u',$ranges['end'] - $ranges['start']));
    header(sprintf('Content-Range: bytes %s-%s/%s', $ranges['start'], $ranges['end'], $file_size));
    fseek($fh, sprintf('%u',$ranges['start']));
}else{
    header("HTTP/1.1 200 OK");
    header(sprintf('Content-Length: %s', $file_size));
}
while(!feof($fh))
{
    echo  fread($fh, round($speed*1024, 0));
    ob_flush();
    sleep(1);
}
($fh != null) && fclose($fh);

基本如此 就可以解决一般性文件的断点续传或者下载

一个可以统计你程序的运行时间长知的php类,有需要的朋友可参考一下。
 代码如下 复制代码
class Timer { 
    private $StartTime = 0;//程序运行开始时间
    private $StopTime  = 0;//程序运行结束时间
    private $TimeSpent = 0;//程序运行花费时间
    function start(){//程序运行开始
        $this->StartTime = microtime(); 
    } 
    function stop(){//程序运行结束
        $this->StopTime = microtime(); 
    } 
    function spent(){//程序运行花费的时间
        if ($this->TimeSpent) { 
            return $this->TimeSpent; 
        } else {
         list($StartMicro, $StartSecond) = explode(" ", $this->StartTime);
         list($StopMicro, $StopSecond) = explode(" ", $this->StopTime);
            $start = doubleval($StartMicro) + $StartSecond;
            $stop = doubleval($StopMicro) + $StopSecond;
            $this->TimeSpent = $stop - $start;
            return substr($this->TimeSpent,0,8)."秒";//返回获取到的程序运行时间差
        } 
    } 

$timer = new Timer(); 
$timer->start();
//...程序运行的代码
$timer->stop();
echo "程序运行时间为:".$timer->spent();
[!--infotagslink--]

相关文章

  • php过滤所有的空白字符(空格、全角空格、换行等)

    在php中自带的trim函数只能替换左右两端的空格,感觉在有些情况下不怎么好使,如果要将一个字符串中所有空白字符过滤掉(空格、全角空格、换行等),那么我们可以自己写一个过滤函数。php学习str_replace函数都知道,可以批量替...2015-10-30
  • 解决vue字符串换行问题(绝对管用)

    这篇文章主要介绍了解决vue字符串换行问题(绝对管用),具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-08-06
  • prettier自动格式化去换行的实现代码

    这篇文章主要介绍了prettier自动格式化去换行的实现代码,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-08-26
  • php过滤所有的空白字符(空格、全角空格、换行等)

    在php中自带的trim函数只能替换左右两端的空格,感觉在有些情况下不怎么好使,如果要将一个字符串中所有空白字符过滤掉(空格、全角空格、换行等),那么我们可以自己写一个过滤函数。php学习str_replace函数都知道,可以批量替...2015-10-30
  • 浅谈Python3中print函数的换行

    这篇文章主要介绍了浅谈Python3中print函数的换行,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-08-05
  • ASP.NET Lable中进行换行解决方案

    这个问题,应该算是很简单的问题,可说实在的,折腾了2个小时的时候,后面整出来的时候,真坑爹呢。现在把这个过程给大家,希望可以给大家一个提醒...2021-09-22
  • C# 字符串多行显示/文本换行以textbox为例讲解

    C# 字符串多行显示、文本换行以textbox为例讲为大家详细介绍并附演示效果图及演示代码,感兴趣的朋友可以了解下,或许对你学习字符串换行有所帮助...2020-06-25
  • 文本超过div 自动换行代码

    文本超过div 自动换行代码文本自动换行IE中解决方法: word-wrap:break-word; word-break:break-all; 注:在要换行的内容相应的单元格或者DIV里加入,如: <div style=word-...2016-09-20
  • php中各种换行符过滤办法

    在php中默认换代码换行有\\n还有一个就是回车换行了/r/n以及我们的ascii编辑的chr(32) chr(13)分别是回车和空格哦,下面是简单介绍不同系统之间的换行符在php中的用法...2016-11-25
  • UTF-8编码怎么去掉BOM头?

    使用uft8编码或做页面的朋友会碰见过把页面保存时会发现页面是空白的但是页面确实有内容,后会会听说是bom头的问题,那么什么是bom头了,要如何解决因为bom头导致页面空白...2016-11-25
  • php过滤或替换textarea换行回车\r\n的2种方法

    如果我们利用textarea提交的数据回车换行与空格都会自动过滤了,所有提交的数据都是没有格式的,下面我们一起来看看解决textarea中回车换行问题。 方法一, 代...2016-11-25
  • meta标记项与导航台排位的关系

    meta的用法   meta是HTML语言中的一个可选的标记项,位于HTML文件的标头部分。在meta标记中定义的文字,在浏览器中并不显示。那么,meta起什么作用呢?  一、m...2016-09-20
  • php将textbox回车符换成html 换行代码

    Mail Body的来源有时直接就是TextBox中的文本内容,但是如果对文本内容没有做处理的话,文本就会没有任何的格式,挤在一起,逐行显示。现在说的是如何让文本内容可以换行,然后...2016-11-25
  • C#给文字换行的小技巧

    这篇文章主要介绍了C#给文字换行的小技巧,本文直接给出实现代码,例子蛮简单,一看就懂啦,需要的朋友可以参考下...2020-06-25
  • c#设置xml内容不换行及属性xsi:nil=true的空节点添加

    c#设置xml内容不换行:添加属性为xsi:nil=true的空节点便可实现,感兴趣的你可以参考下本文,或许有意想不到的收获...2021-09-22
  • MultiLine 换行后实现读取不换行的具体思路

    输入内容中有换行,保存到数据库,直接查看感觉没有换行,但查询结果“以文本格式显示结果”你就会发现 其实是有换行的,下面与大家分享下具体的解决方法...2021-09-22
  • ASP.NET GridView中文本内容无法换行(自动换行/正常换行)

    用GridView来显示课程表,每个单元格的内容包括课程名、上课地点、教师姓名,然后我想让它们分行显示,感兴趣的朋友可以了解下,或许对你有所帮助...2021-09-22
  • 深入Windows下的回车是回车换行(\r\n)还是换行回车(\n\r)的详解

    本篇文章对Windows下的回车是回车换行(\r\n)还是换行回车(\n\r)进行了详细的分析介绍,需要的朋友参考下...2020-04-25
  • 解决numpy数组互换两行及赋值的问题

    这篇文章主要介绍了解决numpy数组互换两行及赋值的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-04-16
  • php中表单输入框中换行回车替换

    php中表单输入框中换行回车替换的一些方法总结,有需要的朋友可参考一下本文章。 代码如下 复制代码 <?php ?$str="this is a test n"; $...2016-11-25