douliangpo0128 2015-10-25 17:40
浏览 87

小于和大于不输出PHP之间的文本

i use (str_replace) function to replace ##ID## in youtube url with this regular expression : (?P<id>[a-z-A-Z_0-9]+) so i use this code to do this :

<?php
  $urlbase = 'https://www.youtube.com/watch?v=##ID##';
  $lastchange = str_replace('##ID##', '(<id>[a-z-A-Z_0-9]+)', $urlbase);
  echo $lastchange;
?>

i get the output in the browser like this : https://www.youtube.com/watch?v=(?P[a-z-A-Z_0-9]+), its looks like <id> not show up !

i try this simple code :

<?php
 echo "This is my <id>";
?>

but i just get this is my in the browser !

What's the probleme ? and how i can fix it , thanks

  • 写回答

3条回答 默认 最新

  • doushang8512 2015-10-25 17:44
    关注

    is being interpreted as HTML so your browser is parsing it and since it is not a renderable element, it shows nothing. Try:

    <?php
      echo "This is my &lt;id&gt;
    ?>
    

    As for the str_replace, it's doing exactly what the function is supposed to be doing. If you're looking to use regular expressions in string replacements, use preg_replace

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度