dongzai3917 2013-01-16 08:59
浏览 360
已采纳

%0D%0A在调用echo时不创建换行符

Every time I try to echo a string there is no new line. I how can I make a newline when calling echo in php using the $_GET?

here is my code:

<?php
    $text = "Hello world";
    $text2 = $_GET['msg'];

    echo $text2
?>

and this is what I enter in the url:

http://localhost/hello.php?msg=hello%0Dworld

or this one:

http://localhost/hello.php?msg=hello%0Aworld

and even this one:

http://localhost/hello.php?msg=hello%0D%0Aworld

The echo has to be a newline please don't say I should use a different method than $_GET. It has to be $_GET

  • 写回答

2条回答 默认 最新

  • doudouxuqh198138 2013-01-16 09:19
    关注

    While performing your exercises you are creating an HTML page.

    HTML is a special markup language, which renders according to set of rules, some of them are:

    • <> characters has a special meaning of control structures named tags
    • all newline characters are ignored
    • to make a newline on the page, one have to use suitable tag - such as <br>, <p> or whatever.

    So, to make a newline appear on your page, you have to convert newline characters to tags. Either use nl2br() function to get a <br /> tag or str_replace() if you want any other one

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器