你的写法没什么错误,你可以这样写:
echo "<script language='javascript'>
      location='abc.php'
      </script>";
其中的javascript你写的可能不正确,请参考document.location.href='aaa.php';

解决方案 »

  1.   

    这样写:
    echo "<script language='javascript'>";
    echo "window.location='abc.php';";
    echo "</script>";
      

  2.   

    你输出的内容是可运行的代码,如果你是要显示在页面上而不是执行,要用htmlspecialchars()来处理。
      

  3.   

    为什么PHP中文手册没把这个翻译出来,难道我下的版本不对?Description
    string htmlspecialchars ( string string [, int quote_style [, string charset]])
    Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with some of these conversions made; the translations made are those most useful for everyday web programming. If you require all HTML character entities to be translated, use htmlentities() instead. This function is useful in preventing user-supplied text from containing HTML up, such as in a message board or guest book application. The optional second argument, quote_style, tells the function what to do with single and double quote characters. The default mode, ENT_COMPAT, is the backwards compatible mode which only translates the double-quote character and leaves the single-quote untranslated. If ENT_QUOTES is set, both single and double quotes are translated and if ENT_NOQUOTES is set neither single nor double quotes are translated. The translations performed are: 
    '&' (ampersand) becomes '&amp;' '"' (double quote) becomes '&quot;' when ENT_NOQUOTES is not set. ''' (single quote) becomes '&#039;' only when ENT_QUOTES is set. '<' (less than) becomes '&lt;' '>' (greater than) becomes '&gt;' 例子 1. htmlspecialchars() example<?php
    $new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
    echo $new; // &lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;
    ?>  
     
    Note that this function does not translate anything beyond what is listed above. For full entity translation, see htmlentities(). Support for the optional second argument was added in PHP 3.0.17 and PHP 4.0.3. 
      

  4.   

    这样吧,把小弟的想法讲出来当mysql建表不成功时,日常是通过die()返回一条错误信息,而小弟是想直接在die()中嵌入以上代码直接跳转到某一网页,请问各位高人,可有更好的方法?BTW:PHP中的直接跳转网页实在麻烦,还是嵌入js好些
      

  5.   

    caslake(菜鸟)、hyw2008(游子意)两位兄好,可能误解小弟的意思了,我是想显示那一段代码,而不是跳转网页,谢谢二位的关注!另外,小弟需要显示在屏幕上这段代码:echo "<script language='javascript'>";
    echo " location='abc.php';";
    echo "</script>";应该是没有语法错误的,谢谢!
      

  6.   

    <?php
    $con=<<<CONTENT
    echo "<script language='javascript'>";
    echo " location='abc.php';";
    echo "</script>";
    CONTENT;
    echo htmlspecialchars($con);
    ?>
    htmlspecialchars()作用就是将'&' '"' ''' '<' '>' 分别转换成 '&amp;' '&quot;' '&#039;' '&lt;' '&gt;'
      

  7.   

    跳出对话框:echo "<script language='javascript'>";
    echo "alert('abc.php');";
    echo "</script>";
    显示“abc.php”。
      

  8.   


    echo "<script language='javascript'>";
    echo "location.href='abc.php';";
    echo "</script>";
      

  9.   

    太多echo了,不需要echo另一个echo
      

  10.   

    以下两种法子都可以实现啊!1.//header("Location: view.php");2.//echo"<script>window.location='view.php';</script>";
      

  11.   

    唉,简单问题搞的这么复杂。1. @header("Location: xxx.php"); //header以前不要有任何输出2. echo " <script language=\"JavaScript\">window.location.href=\"xxx.php\";</script> ";
      

  12.   

    通常的写法
    mysql_query('create table ....') or die(错误信息);跳转的写法
    mysql_query('create table ....') or header(目标地址);$js = <<< JS
    <script language='javascript'>
    location='abc.php';
    </script>
    JS;用js跳转的写法
    mysql_query('create table ....') or die($js);将js代码显示在页面上
    echo htmlspecialchars($js);