dongzhu7329 2019-05-01 15:50
浏览 26
已采纳

如何修复PHP中的双/单引号[重复]

This question already has an answer here:

this should be an easy question but im finding it hard to get a working answer, i am using Sendgrid php api and it requires that i do the following code in this layout.

in my code i have:

//this part is the sendgrid part:
$email->addContent(
    "text/html", "//i need to put the bottom image code into here"

<?php echo '<img src="data:image/png;base64,'.base64_encode($portal['image']).'"width="1024px" height="768px"/>'; ?>




the end result should look something like:

$email->addContent(
    "text/html", "<img src="data:image/png;base64,'.base64_encode($portal['image']).'"width="1024px" height="768px"/>"


i cant figure out how to use the correct quotes so that this code will work since it uses double and single quotes inside of eachother

</div>
  • 写回答

1条回答 默认 最新

  • dongying9756 2019-05-01 15:58
    关注

    You have to match the starting and ending quotes for a string. You're starting the first string with ", but then ending it with ' before the concatenation ..

    If you want to put double quotes inside the string, use single quotes around it, and vice versa. If you need to include the same kind of quote inside the string as you use two create it, you have to escape the inner one.

    $email->addContent(
        "text/html", '<img src="data:image/png;base64,'.base64_encode($portal['image']).'" width="1024px" height="768px"/>'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)