代码之家  ›  专栏  ›  技术社区  ›  rupesh

在Sweet alert 2中传递PHP variabe

  •  1
  • rupesh  · 技术社区  · 7 年前

    我想在sweet alert中显示PHP变量,但找不到解决方案,我查阅了sweet alert 2的文档,但找不到任何东西。 有人能帮我吗?

    $name = "xyz";
    
    //sweetalert code
    echo "<script>";
    echo 'setTimeout(function () { swal("Greetings $name!","Thank you for adding your business details.<br>Our admin team will review the same and will publish shortly..!","success");';
    echo '}, 100);</script>';
    
    2 回复  |  直到 7 年前
        1
  •  2
  •   Thamilhan    7 年前

    echo "setTimeout(function () { swal('Greetings $name!','Thank you for adding your business details.<br>Our admin team will review the same and will publish shortly..!','success');'";
    

    echo 'setTimeout(function () { swal("Greetings ' . $name . '!","Thank you for adding your business details.<br>Our admin team will review the same and will publish shortly..!","success");';
    

    在echo中包含变量时,需要使用 "

    了解两者之间的区别 " ' 另一个 SO Answer


        2
  •  0
  •   Rakesh kumar    7 年前

    echo 'setTimeout(function () { swal("Greetings"'.$name.'"!","Thank you for adding your business details.<br>Our admin team will review the same and will publish shortly..!","success");';