php - 是否有类似 ASP.NET MVC 的 PHP 函数 nl2br() 的东西?

标签 php asp.net-mvc

是否有标准函数可以换行到<br />在 ASP.Net MVC 中编码?

最佳答案

现在有:

public static class StockStandardFunctions
{
    public static string Nl2br(this string input)
    {
        return input.Nl2br(true);
    }

    public static string Nl2br(this string input, bool is_xhtml)
    {
        return input.Replace("\r\n", is_xhtml ? "<br />\r\n" : "<br>\r\n");
    }
}

修改为更严格地遵循 nl2br 的 php 规范(感谢 Max 指出)。这仍然假设\r\n 换行......

关于php - 是否有类似 ASP.NET MVC 的 PHP 函数 nl2br() 的东西?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2738192/

相关文章:

javascript - 设置文本区域中各行的样式

php - 如何在单个 while 循环中从多个查询中检索值?

session_id() 和 session_start() 的 PHP 逻辑

jquery - 如何使用ajax和其他附加字段上传文件?

c# - 强类型 T4MVC Action /ActionLink

c# - ASP.NET MVC - 从 MemoryStream 下载 Excel 文件(损坏的文件)

asp.net-mvc - "processing"错误消息将 MVC4 部署到 Elastic Beanstalk

php - 在 Magento 中为产品设置特价日期

php - FreeTDS 奇怪的日期时间格式

.net - 如何修复 System.Data.Edm.EdmEntityType 没有键