dongyu1979 2018-02-27 07:08
浏览 41
已采纳

在PHP中将HTML Dom转换为字符串[关闭]

An HTML DOM Contains characters such as id="xyz" or class:'col-md-3'. The problem is I have a PHP script which converts PHP variable to strings. But one of my variable contains HTML dom elements. I am having a hard time to convert that variable into a string.

My code:

 foreach($result as $n){

$message1 = '"'.(string)$n['Message'].'"';
$message = "'".(string)addslashes($message1)."'";

{

error:

/><br /><table style=\'border:1px solid...
                             ^ - error 1
AT <span id="cat_id"
            ^ - error 2
",\"
  ^ -error 3
  • 写回答

1条回答 默认 最新

  • dqtm8504 2018-02-27 07:22
    关注

    I am not what you really want to achieve but something like below could help I guess.

    $message = "'".(string)addslashes('"'.$messag1.'"')."'";
    echo $message;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?