2012-02-24 125 views
0

我有獲取我,我現在用我使用PHP的簡單的HTML DOM parser.The代碼中嵌入代碼的腳本是這樣的:獲取HTML標記作爲字符串

 foreach ($html->find('object embed') as $embedCode) 
      { 

       echo $embedCode; 

      } 

和出是放:

 <embed width="100%" height="320" flashvars="config=http://server0.stream2k.com/playerjw/vConfigCdn.php?vkey=c2053010dadfdd331145" 
     allowfullscreen="true" allowscriptaccess="always" 
     src="http://server0.stream2k.com/playerjw/player-licensed56.swf" 
     pluginspage="http://www.macromedia.com/go/getflashplayer" 
     type="application/x-shockwave-flash" wmode="transparent"> 

但它顯示在我的瀏覽器中作爲閃光screen.I要打印它作爲一個單一的字符串。

誰能告訴我怎樣才能得到它作爲一個字符串沒有視頻畫面。

在此先感謝

GetMovie()的返回:

   <embed wmode="transparent" type="application/x-shockwave- flash"    
       pluginspage="http://www.macromedia.com/go/getflashplayer" 
       src="http://server0.stream2k.com/playerjw/player- licensed56.swf"     
       width="100%" height="320" allowscriptaccess="always" allowfullscreen="true" flashvars="config=http://server0.stream2k.com/playerjw/vConfigCdn.php?vkey=f3513b19d1149102e116" /> 
+0

單串是什麼意思? – Sarfraz 2012-02-24 08:48:38

+1

因爲它的聲音......在單(單指一個(一個意思 - > 1))變量$ a = desiredTagsAsString – 2012-02-24 09:09:59

回答

2

使用的htmlspecialchars:

foreach ($html->find('object embed') as $embedCode) 
      { 

       echo htmlspecialchars($embedCode); 

      } 
+0

我可以挑選嵌入代碼發送到我的數據庫字符串? – 2012-02-24 09:01:25

+0

我需要的用htmlspecialchars扔數據庫作爲源code..is這可能嗎?我試着用mysel_escape_string..but它不工作 – 2012-02-24 09:11:17

+0

是的,當然。爲什麼不?只記得關於mysql_real_escape_string – Anthony 2012-02-24 09:13:14

1

試圖把輸出字符串中的htmlspecialchars:echo htmlspecialchars($embedCode);

+0

我可以選擇它:$ code = htmlspecialchars($ embedCode);併發送到數據庫? – 2012-02-24 09:11:54

+0

是的,在你的桌子裏面代碼將被這樣存儲:<strong> ......即HTML標籤將以這種方式編碼,瀏覽器不會將它們解釋爲代碼,而是作爲簡單的文本。 – bodi0 2012-02-24 09:19:06

0

你可以嘗試像這樣:

<pre> 
    &#60;embed width="100%" height="320" flashvars="config=http://server0.stream2k.com/playerjw/vConfigCdn.php?vkey=c2053010dadfdd331145" 
    allowfullscreen="true" allowscriptaccess="always" 
    src="http://server0.stream2k.com/playerjw/player-licensed56.swf" 
    pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"> 
​</pre> 

0

之前,儘量增加你的這個 「for」 循環:

echo '<xmp>'; 

這將回顯所有字符,但不顯示爲HTML代碼。