PHP语法错误。似乎无法找到修复

时间:2012-12-20 03:31:36

标签: php syntax

有谁可以指出如何解决我得到的2个语法错误?我对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

3 个答案:

答案 0 :(得分:2)

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

您正在尝试将js保存为字符串,但是您已经使用了js代码。这搞砸了。你只需要逃避那些单引号。将主要内部的那些从'更改为'。这应该解决它。

答案 1 :(得分: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 :(得分:2)

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

在上图中,我尽可能地描述了问题!