如何在PHP中使用Flex中的换行符 [英] How to use line breaks in Flex with PHP string

查看:166
本文介绍了如何在PHP中使用Flex中的换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的MXML

 < mx:Text id =namestyleName =textStylemaxWidth = 400 >< / MX:文本和GT; 

然后在同一个文件中:

 < MX:脚本> 
<![CDATA [

private function init():void
{
name.text = data.string;
}

]]>
< / mx:Script>

data.string 来自数据库,它包含这个:

 这是一个带两行的字符串\\\

我也试过这个:

 这是一个两行的字符串。 

它们都没有在flex中创建新行,它们都以 \\\
&#13;



如果我输入 \\\
这样的话,可以这样做:

在代码中:

  name.text =test \\\
test;

但是如果我做了 name.text = data.string; 即使 data.string 的值完全相同。


$ b

  string.split( \\\\
)加入( \\\
);


This is the MXML I have

<mx:Text id="name" styleName="textStyle" maxWidth="400"></mx:Text>

Then in the same file I have :

<mx:Script>
    <![CDATA[

    private function init():void
    {
       name.text = data.string;
    }

    ]]>
</mx:Script>

data.string comes from the DB and it contains this :

"This is a string \n with two lines."

I also tried this :

"This is a string &#13; with two lines."

None of them create a new line in flex they are both rendered to the screen as \n and &#13;.

How can I create a new line with a string that is coming from the database?

If I type \n like this in the code it works :

name.text = "test \n test"; 

but if I do name.text=data.string; it doesn't even though data.string has the exact same value.

解决方案

If I run this on the string coming from the DB it works:

string.split("\\n").join("\n");

这篇关于如何在PHP中使用Flex中的换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆