2012-12-20 31 views
0

任何人都可以指出如何解決我得到的2個語法錯誤?我不是很高級的PHP。PHP語法錯誤。似乎可以找到修復

這裏是代碼:

$code = '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script> 
     <script> 
     <table id="slideleft" style=" overflow:auto; position:fixed; top:25%;"><tr class="slideLeftItem" style="position:fixed;left:-320px;z-index:1000;height:100%;"><td><img src="https://lh3.googleusercontent.com/-GMJe-Am-U9Q/T4p4bZu7jDI/AAAAAAAAAFs/qQqmMGn-wwg/s800/facebook-vertical.png" style="top:5px; position:absolute; border-left-width:5px; left:318px;"/></td><td class="contentBox" style="border:solid 5px #5370AD; width:300px;height:300px;position:relative;border-radius:5px;background-color:white;"><div id="fb-root"></div><script type="text/javascript" >(function() {var e = document.createElement('script'); e.async = true;e.src = document.location.protocol +'//connect.facebook.net/en_US/all.js#xfbml=1';document.getElementById('fb-root').appendChild(e);());</script> 

     <fb:like-box href="https://www.facebook.com/ExplicitWebsiteDesign?ref=hl" width="300" show_faces="true" stream="false" header="false"></fb:like-box></td></tr></table><script type="text/javascript">jQuery(".slideLeftItem").append('<div style="font-size:12px;font-family: arial;width:300px;text-align:right;"><a rel="dofollow" href="http://techbrij.com/944/add-social-slider-widget-website" style="background-color:#D2C9CA;padding:3px 7px;font-weight:bold;color:#516FA9">Get This Widget</a></div>');jQuery("#slideleft tr").hover(function(b){var a=jQuery(this);jQuery("#slideleft tr").not(a).hide();a.css({"z-index":"9999"});a.stop().animate({left:0})},function(b){var a=jQuery(this);a.css({"z-index":"1000"});a.stop().animate({left:-a.outerWidth()});jQuery("#slideleft tr").show()});</script>}</script>'; 

而且下面的圖片是截圖我的代碼...謝謝。

enter image description here

+11

你能讀懂這段代碼嗎?我不能。 –

+1

還有這麼多的語法錯誤! –

+0

什麼是語法錯誤?你確定他們是PHP錯誤,而不是JS? – Mawg

回答

2
$code = ' (function() {var e = document.createElement('scr 

您試圖保存JS爲字符串,但你在你的js代碼有'。這弄亂了它。你只需要逃避那些單引號。將主要內容中的內容從''更改爲\'。這應該解決它。

2

嘗試使用output buffer你的優勢:

ob_start(); 
?> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script> 
     <script> 
     <table id="slideleft" style=" overflow:auto; position:fixed; top:25%;"><tr class="slideLeftItem" style="position:fixed;left:-320px;z-index:1000;height:100%;"><td><img src="https://lh3.googleusercontent.com/-GMJe-Am-U9Q/T4p4bZu7jDI/AAAAAAAAAFs/qQqmMGn-wwg/s800/facebook-vertical.png" style="top:5px; position:absolute; border-left-width:5px; left:318px;"/></td><td class="contentBox" style="border:solid 5px #5370AD; width:300px;height:300px;position:relative;border-radius:5px;background-color:white;"><div id="fb-root"></div><script type="text/javascript" >(function() {var e = document.createElement('script'); e.async = true;e.src = document.location.protocol +'//connect.facebook.net/en_US/all.js#xfbml=1';document.getElementById('fb-root').appendChild(e);());</script> 

     <fb:like-box href="https://www.facebook.com/ExplicitWebsiteDesign?ref=hl" width="300" show_faces="true" stream="false" header="false"></fb:like-box></td></tr></table><script type="text/javascript">jQuery(".slideLeftItem").append('<div style="font-size:12px;font-family: arial;width:300px;text-align:right;"><a rel="dofollow" href="http://techbrij.com/944/add-social-slider-widget-website" style="background-color:#D2C9CA;padding:3px 7px;font-weight:bold;color:#516FA9">Get This Widget</a></div>');jQuery("#slideleft tr").hover(function(b){var a=jQuery(this);jQuery("#slideleft tr").not(a).hide();a.css({"z-index":"9999"});a.stop().animate({left:0})},function(b){var a=jQuery(this);a.css({"z-index":"1000"});a.stop().animate({left:-a.outerWidth()});jQuery("#slideleft tr").show()});</script>}</script> 
<?php 
$code = ob_get_clean(); 
2

In the above image I described the problem as best as I can!

在上圖中我最佳描述的問題,因爲我能!

+0

我現在得到了腳本標籤,爲什麼他們只能看到紅線! –

+0

你高調的那個人並沒有結束這段代碼。 '腳本'之前的那個結束了代碼,因此它被認爲是PHP並給出了錯誤。如果你看起來很接近的腳本是黑色的,並不像其他的那樣高亮。 – khuderm

相關問題