| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> php >> zai PHP zhong xian shi ge shi hua de yong hu shu ru

zai PHP zhong xian shi ge shi hua de yong hu shu ru

2008-12-22 08:10:37 编辑來源:互联网 评论
 
 
 
本文为【在PHP中显示格式化的用户输入】的拼音翻译版
  wo men jiang tao lun mei you jing guo guo lv de shu chu de wei xian , gei chu yi ge an quan de xian shi ge shi hua shu chu de fang fa 。
  mei you guo lv shu chu de wei xian
  ru guo ni jin jin huo de yong hu de shu ru ran hou xian shi ta , ni ke neng hui po huai ni de shu chu ye mian , ru yi xie ren neng e yi di zai ta men ti jiao de shu ru kuang zhong qian ru javascript jiao ben :
  This is my comment.
  <script language="javascript:
  alert('Do something bad here!')">.
  zhe yang , ji shi yong hu bu shi e yi de , ye hui po huai ni de yi xie HTML de yu ju , ru yi ge biao ge tu ran zhong duan , huo shi ye mian xian shi bu wan zheng 。
  zhi xian shi wu ge shi de wen ben
  zhe shi yi ge zui jian dan de jie jue fang an , ni zhi shi jiang yong hu ti jiao de xin xi xian shi wei wu ge shi de wen ben 。 shi yong htmlspecialchars() han shu , jiang zhuan hua quan bu de zi fu wei HTML de bian ma 。
  ru <b> jiang zhuan bian wei <b>, zhe ke yi bao zheng bu hui you yi xiang bu dao de HTML biao ji zai bu shi dang de shi hou shu chu 。
  zhe shi yi ge hao de jie jue fang an , ru guo ni de yong hu zhi guan zhu mei you ge shi de wen ben nei rong 。 dan shi , ru guo ni gei chu yi xie ke yi ge shi hua de neng li , ta jiang geng hao yi xie 。
  Formatting with Custom Markup Tags
  yong hu zi ji de biao ji zuo ge shi hua
  ni ke yi ti gong te shu de biao ji gei yong hu shi yong , li ru , ni ke yi yuan xu shi yong ... jia chong xian shi ,... xie ti xian shi , zhe yang zuo jian dan de cha zhao ti huan cao zuo jiu ke yi le : $output = str_replace("", "<b>", $output);
  $output = str_replace("", "<i>", $output);
  zai zuo de hao yi dian , wo men ke yi yuan xu yong hu jian ru yi xie lian jie 。 li ru , yong hu jiang yuan xu shu ru [link="url"]...[/link], wo men jiang zhuan huan wei <a href="">...</a> yu ju
  zhe shi , wo men bu neng shi yong yi ge jian dan de cha zhao ti huan , ying gai shi yong zheng ze biao da shi jin xing ti huan :
  $output = ereg_replace('[link="([[:graph:]]+)"]', '<a href="1">', $output);
  ereg_replace() de zhi xing jiu shi :
  cha zhao chu xian [link="..."] de zi fu chuan , shi yong <a href="..."> ti huan ta
  [[:graph:]] de han yi shi ren he fei kong zi fu , you guan zheng ze biao da shi qing kan xiang guan de wen zhang 。
  zai outputlib.php de format_output() han shu ti gong zhe xie biao ji de zhuan huan , zong ti shang de yuan ze shi : zhong guo wang guan lian meng bitsCN.com
  tiao yong htmlspecialchars() jiang HTML biao ji zhuan huan cheng te shu bian ma , jiang bu gai xian shi de HTML biao ji guo lv diao , ran hou , jiang yi xi lie wo men zi ding yi de biao ji zhuan huan xiang ying de HTML biao ji 。
  qing shen kan xia mian de yuan dai ma :
  <?php
  function format_output($output) {
  /****************************************************************************
  * Takes a raw string ($output) and formats it for output using a special
  * stripped down markup that is similar to HTML
  ****************************************************************************/
  $output = htmlspecialchars(stripslashes($output));
  /* new paragraph */
  $output = str_replace('[p]', '<p>', $output);
  /* bold */
  $output = str_replace('[b]', '<b>', $output);
  $output = str_replace('
', '</b>', $output);
  /* italics */
  $output = str_replace('[i]', '<i>', $output);
  $output = str_replace('
', '</i>', $output); wang guan bitscn_com
  /* preformatted */
  $output = str_replace('[pre]', '<pre>', $output);
  $output = str_replace('[/pre]', '</pre>', $output);
  /* indented blocks (blockquote) */
  $output = str_replace('[indent]', '<blockquote>', $output);
  $output = str_replace('[/indent]', '</blockquote>', $output);
  /* anchors */
  $output = ereg_replace('[anchor="([[:graph:]]+)"]', '<a name="\1"></a>', $output);
  /* links, note we try to prevent javascript in links */
  $output = str_replace('[link="javascript', '[link=" javascript', $output);
  $output = ereg_replace('[link="([[:graph:]]+)"]', '<a href="\1">', $output);
  $output = str_replace('[/link]', '</a>', $output);
  return nl2br($output);
  }
  ?>
  yi xie zhu yi de di fang :
  ji zhu ti huan zi ding yi biao ji sheng cheng HTML biao ji zi fu chuan shi zai tiao yong htmlspecialchars() han shu zhi hou , er bu shi zai zhe ge tiao yong zhi qian , fou ze ni de jian ku de gong zuo zai tiao yong htmlspecialchars() hou jiang fu zhi dong liu 。 wang guan bitscn_com
  zai jing guo zhuan huan zhi hou , cha zhao HTML dai ma jiang shi ti huan guo de , ru shuang yin hao " jiang cheng wei "
  nl2br() han shu jiang hui che huan xing fu zhuan huan wei <br> biao ji , ye yao zai htmlspecialchars() zhi hou 。
  dang zhuan huan [links=""] dao <a href="">, ni bi xu que ren ti jiao zhe bu hui cha ru javascript jiao ben , yi ge jian dan de fang fa qu geng gai [link="javascript dao [link=" javascript, zhe zhong fang shi jiang bu ti huan , zhi shi jiang yuan ben de dai ma xian shi chu lai 。
  outputlib.php
  zai liu lan qi zhong tiao yong test.php, ke yi kan dao format_output() de shi yong qing kuang
  zheng chang de HTML biao ji bu neng bei shi yong , yong xia lie de te shu biao ji ti huan ta :
  - this is bold
  - this is italics
  - this is [link="http://www.phpbuilder.com"]a link[/link]
  - this is [anchor="test"]an anchor, and a [link="#test"]link[/link] to the anchor
  [p] duan luo
  [pre] yu xian ge shi hua [/pre]
  [indent] jiao cuo wen ben [/indent]
  zhe xie zhi shi hen shao de biao ji , dang ran , ni ke yi gen ju ni de xu qiu sui yi jia ru geng duo de biao ji wang guan lian meng bitsCN@com
  Conclusion
  jie lun
  zhe ge tao lun ti gong an quan xian shi yong hu shu ru de fang fa , ke yi shi yong zai xia lie cheng xu zhong
  liu yan ban
  yong hu jian yi
  xi tong gong gao
  BBS xi tong【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
wo men jiang tao lun mei you jing guo guo lv de shu chu de wei xian , gei chu yi ge an quan de xian shi ge shi hua shu chu de fang fa 。    mei you guo lv shu chu de wei xian    ru guo ni jin jin huo de yong hu de shu ru ran hou xian shi ta , ni ke neng hui po huai ni de shu chu ye mian , ru yi xie ren neng e yi di zai ta men ti jiao de shu ru kuang zhong qian ru javascript jiao ben : This is my comment. <script language="javascript: alert('Do something bad here!')">.    zhe yang , ji shi yong hu bu shi e yi de , ye hui po huai ni de yi xie HTML de yu ju , ru yi ge biao ge tu ran zhong duan , huo shi ye mian xian shi bu wan zheng 。    zhi xian shi wu ge shi de wen ben    zhe shi yi ge zui jian dan de jie jue fang an , ni zhi shi jiang yong hu ti jiao de xin xi xian shi wei wu ge shi de wen ben 。 shi yong htmlspecialchars() han shu , jiang zhuan hua quan bu de zi fu wei HTML de bian ma 。    ru <b> jiang zhuan bian wei <b>, zhe ke yi bao zheng bu hui you yi xiang bu dao de HTML biao ji zai bu shi dang de shi hou shu chu 。    zhe shi yi ge hao de jie jue fang an , ru guo ni de yong hu zhi guan zhu mei you ge shi de wen ben nei rong 。 dan shi , ru guo ni gei chu yi xie ke yi ge shi hua de neng li , ta jiang geng hao yi xie 。 Formatting with Custom Markup Tags yong hu zi ji de biao ji zuo ge shi hua    ni ke yi ti gong te shu de biao ji gei yong hu shi yong , li ru , ni ke yi yuan xu shi yong [b]...[/b] jia chong xian shi ,[i]...[/i] xie ti xian shi , zhe yang zuo jian dan de cha zhao ti huan cao zuo jiu ke yi le : $output = str_replace("[b]", "<b>", $output); $output = str_replace("[i]", "<i>", $output);    zai zuo de hao yi dian , wo men ke yi yuan xu yong hu jian ru yi xie lian jie 。 li ru , yong hu jiang yuan xu shu ru [link="url"]...[/link], wo men jiang zhuan huan wei <a href="">...</a> yu ju    zhe shi , wo men bu neng shi yong yi ge jian dan de cha zhao ti huan , ying gai shi yong zheng ze biao da shi jin xing ti huan : $output = ereg_replace('[link="([[:graph:]]+)"]', '<a href="\1">', $output); ereg_replace() de zhi xing jiu shi : cha zhao chu xian [link="..."] de zi fu chuan , shi yong <a href="..."> ti huan ta [[:graph:]] de han yi shi ren he fei kong zi fu , you guan zheng ze biao da shi qing kan xiang guan de wen zhang 。    zai outputlib.php de format_output() han shu ti gong zhe xie biao ji de zhuan huan , zong ti shang de yuan ze shi : zhong guo wang guan lian meng bitsCN.com    tiao yong htmlspecialchars() jiang HTML biao ji zhuan huan cheng te shu bian ma , jiang bu gai xian shi de HTML biao ji guo lv diao , ran hou , jiang yi xi lie wo men zi ding yi de biao ji zhuan huan xiang ying de HTML biao ji 。 qing shen kan xia mian de yuan dai ma : <?php function format_output($output) { /**************************************************************************** * Takes a raw string ($output) and formats it for output using a special * stripped down markup that is similar to HTML ****************************************************************************/ $output = htmlspecialchars(stripslashes($output)); /* new paragraph */ $output = str_replace('[p]', '<p>', $output); /* bold */ $output = str_replace('[b]', '<b>', $output); $output = str_replace('[/b]', '</b>', $output); /* italics */ $output = str_replace('[i]', '<i>', $output); $output = str_replace('[/i]', '</i>', $output); wang guan bitscn_com /* preformatted */ $output = str_replace('[pre]', '<pre>', $output); $output = str_replace('[/pre]', '</pre>', $output); /* indented blocks (blockquote) */ $output = str_replace('[indent]', '<blockquote>', $output); $output = str_replace('[/indent]', '</blockquote>', $output); /* anchors */ $output = ereg_replace('[anchor="([[:graph:]]+)"]', '<a name="\1"></a>', $output); /* links, note we try to prevent javascript in links */ $output = str_replace('[link="javascript', '[link=" javascript', $output); $output = ereg_replace('[link="([[:graph:]]+)"]', '<a href="\1">', $output); $output = str_replace('[/link]', '</a>', $output); return nl2br($output); } ?> yi xie zhu yi de di fang :    ji zhu ti huan zi ding yi biao ji sheng cheng HTML biao ji zi fu chuan shi zai tiao yong htmlspecialchars() han shu zhi hou , er bu shi zai zhe ge tiao yong zhi qian , fou ze ni de jian ku de gong zuo zai tiao yong htmlspecialchars() hou jiang fu zhi dong liu 。 wang guan bitscn_com    zai jing guo zhuan huan zhi hou , cha zhao HTML dai ma jiang shi ti huan guo de , ru shuang yin hao " jiang cheng wei " nl2br() han shu jiang hui che huan xing fu zhuan huan wei <br> biao ji , ye yao zai htmlspecialchars() zhi hou 。    dang zhuan huan [links=""] dao <a href="">, ni bi xu que ren ti jiao zhe bu hui cha ru javascript jiao ben , yi ge jian dan de fang fa qu geng gai [link="javascript dao [link=" javascript, zhe zhong fang shi jiang bu ti huan , zhi shi jiang yuan ben de dai ma xian shi chu lai 。 outputlib.php zai liu lan qi zhong tiao yong test.php, ke yi kan dao format_output() de shi yong qing kuang zheng chang de HTML biao ji bu neng bei shi yong , yong xia lie de te shu biao ji ti huan ta : - this is [b]bold[/b] - this is [i]italics[/i] - this is [link="[url=http://www.phpbuilder.com]http://www.phpbuilder.com"]a[/url] link[/link] - this is [anchor="test"]an anchor, and a [link="#test"]link[/link] to the anchor [p] duan luo [pre] yu xian ge shi hua [/pre] [indent] jiao cuo wen ben [/indent] zhe xie zhi shi hen shao de biao ji , dang ran , ni ke yi gen ju ni de xu qiu sui yi jia ru geng duo de biao ji wang guan lian meng [url=mailto:bitsCN@com]bitsCN@com[/url] Conclusion    jie lun    zhe ge tao lun ti gong an quan xian shi yong hu shu ru de fang fa , ke yi shi yong zai xia lie cheng xu zhong liu yan ban yong hu jian yi xi tong gong gao BBS xi tong
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
华丽的模特拍摄(8)
华丽的模特拍摄(7)
华丽的模特拍摄(6)
华丽的模特拍摄(5)
八里沟
朝阳宫
天下峨眉 云上金顶
老家(四)
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有