我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

too long

I want to use { in a string which is being stored in heredoc in PHP, how to use it? how to escape?

echo $heredoc = <<<HTML
<p>
    Welcome {$myname}
</p>
HTML;

The output is Welcome Aayush Sinha

But the output required is Welcome {Aayush Sinha}.

You should wrap it around another pair of curly braces

echo $heredoc = <<<HTML
<p>
     Welcome {{$myname}}
</p>
HTML;

That will do the job.

Output: Welcome {Aayush Sinha}.

近期文章

  • too long
  • too long
  • too long
  • 使用Htaccess Mod Rewrite创建SEO友好URL
  • too long
  • 如何使用具有数组的jquery处理新字段
  • .htaccess要求我多退出一个目录
  • 从自定义搜索表单中获取数据并在页面中显示结果(wordpress)
  • 即使设置了tmpdir,php文件上传返回错误6
  • 为什么php.ini文件路径不一样?
  • PHP邮件仅适用于我的servermail
  • too long
  • 如何在视图文件中显示数据
  • 通过Android连接到PHP的问题
  • 不能从数据库setcellvalue但静态值工作?
  • 仅在条件下运行函数
  • 为什么我不能从数据库中设置值,但硬编码值工作正常?
  • LDAP / SSO Intranet解决方案
  • 如果单击链接,则更改div的内容
  • 显示父类别而不是第一类 - Wordpress

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华