1

我有一些 GD/PHP 代码试图从字符串(保存在 PHP 变量中)创建图像。虽然输出很奇怪..

这是代码:(看起来开始时有一堆空白,但那是因为我缩进在这里插入它,我仍然不明白如何正确使用Stackoverflow的代码插入功能:/在我的实际代码中有没有这种过多的空格。

<?php 
        session_start(); 

        //If user is not logged in
        if(!isset($_SESSION['username']))
        {
            //They aren't meant to be able to access this page. GET THEM OUT OF HERE!
            echo "<script language=\"javascript\">top.location=\"index.php\";</script>";
            echo "<script language=\"javascript\">alert('You need to be logged in to access this page.');</script>";
        }   else
            {

                //Localise.
                $username = $_SESSION['username'];

                //Include important settings and functions.
                include($_SERVER['DOCUMENT_ROOT'] . '/includes/config.php');

                //Connect to MySQL Database.
                include($_SERVER['DOCUMENT_ROOT'] . '/includes/connect.php');

                //Let's get the users id.
                $sql = "SELECT * FROM `users` WHERE `username` = '$username'";
                $result = mysql_query($sql) or die(mysql_error());
                if(mysql_num_rows($result))
                {
                    $userarray = mysql_fetch_array($result) or die(mysql_error());  
                    $userid = $userarray['id'];
                }
            }

        if(!$_GET['i'] || $_GET['id'] != '95dd76e1099af307a37804ecb4d820bd' || $_GET['arid'] != 'b691362f280e16e9a5136d1623ac8156')
        {
            echo "<script language=\"javascript\">alert('There was an error with your request.');</script>";
            echo "<script language=\"javascript\">top.location=\"members.php\";</script>";
        }   else
            {
                //Decode and localise.
                $articletitle = urldecode($_GET['i']);  
            }
    ?>
    <!DOCTYPE html>
    <!--[if IE 7 ]>    <html class="ie7 oldie"> <![endif]-->
    <!--[if IE 8 ]>    <html class="ie8 oldie"> <![endif]-->
    <!--[if IE 9 ]>    <html class="ie9"> <![endif]-->
    <!--[if (gt IE 9)|!(IE)]><!--> <html> <!--<![endif]-->

    <head>

        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
        <meta charset="utf-8"/>
        <meta name="description" content="">
        <meta name="author" content="">

        <title>5StarWriters</title>

        <link rel="stylesheet" type="text/css" media="screen" href="css/style.css" />

        <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="js/jquery-1.6.1.min.js"><\/script>')</script>

        <script src="js/scrollToTop.js"></script>

    </head>

    <body id="top">

    <!--header -->
    <div id="header-wrap"><header>

            <hgroup>
            <h1><a href="index.html">5StarWriters</a></h1>
            <h3>Quality content, fast.</h3>
        </hgroup>

            <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/navlogged.php'); ?>

            <!-- Login bar can go here -->

    <!--/header--> </header></div>

    <!-- content-wrap -->
    <div id="content-wrap">

        <!-- content -->
        <div id="content" class="clearfix">

            <!-- main -->
            <div id="main">
                <?php
                    $sql = "SELECT `id` FROM `articles` WHERE `title` = '$articletitle'";
                    $result = mysql_query($sql) or die(mysql_error());
                    $array = mysql_fetch_array($result) or die(mysql_error());
                    $articleid = $array['id'];

                    $sql2 = "SELECT * FROM `pendingreview` WHERE `requestid` = '$userid' AND `articleid` = '$articleid'";
                    $result2 = mysql_query($sql2) or die(mysql_error());
                    //unset($array); //Clear variable data.
                    $array = mysql_fetch_array($result2); //Lets reload it with some more useful data.

                    //$sql = "SELECT * FROM `pendingreview` WHERE `requestid` = '$userid' AND ";
                    //$result = mysql_query($sql) or die(mysql_error());
                ?>
                <center><h1>Pending Review<h1></center>
                <br />
                <center>

    <?php
    $text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";

    $arrText=explode("\n",wordwrap($text,75,"\n"));//change number 75 here to check the wordwrap

    $im = @imagecreate(700,500); //creates an image (width,height)
    $background_color = imagecolorallocate($im, 0, 0, 0); //sets image background color
    $y=5; //vertical position of text
    foreach($arrText as $arr)
    {
      $white=imagecolorallocate($im,255,255,255); //sets text color
      imagestring($im,5,15,$y,trim($arr),$white); //create the text string for image,added trim() to remove unwanted chars
      $y=$y+15;

    }
    header("Content-type: image/png");
    imagepng($im);
    imagedestroy($im);
    ?>

                </center>
                <br /><br /><center>
                </center>
                <br /><br /><br /><br />
            <!-- /main -->
            </div>

            <!-- sidebar -->
            <div id="sidebar">

                <div class="about-me">
                        <!-- SIDEBAR CONTENT HERE -->
                </div>

                <div class="sidemenu">

                    <!-- Extra sidebar content -->
                </div>

            <!-- /sidebar -->
            </div>

        <!-- content -->
        </div>

    <!-- /content-out -->
    </div>

    <!-- footer -->
    <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'); ?>
    </body>
    </html>

这是输出:

�PNG IHDR����PLTE���������������������������������������������� ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ������������������������������������������������������ ����������������������= IDATx��X ��44�,�BB @������'��K]G��53 /Qa�-�Q]]��;MÆ 6lذaÆ 6lذaÆ 6�S�/������)��,����z�z_�Ό��H�<3�rc��w!|=�m�>n���� n�x��As�9�uxֈ�M?�����R&... �R����&��/0j-������L _3�zW�QN�;�f#��t�x����D$Ž�<�(�#�<� C�yL�_p���L�6y�X��X�G�qC��}��&��ej��(#ː�j��H�5[����xX�vT,1 �m"�e��5���c%ak��ra4�)��z�[f�#^#xE�'�7�;��W)V����� ӡޛ�!' =U�SN����[�� �1ċW�m��7��c�o��&�N�i7-�T��'���Q�tz�x+�R�)�/� H�噼��a�W��u�[�"LID��[��ͨ0%�N|��@f�<code>J:�v�P���N�E�& ��/��E��"��v4*8�[���4��4�5Q�g����ב+��$J9䢺�C�-4h��Y�|ыGI� /���R'�a7(�%R��l�:�v�]y$I���w�1 �Iۮy�Ǿ/�͞iW|o�.�x,�e��5����c%ak��ra4�)��z�[f�#^#xE�'�7�;��W)V�����ӡޛ�!�=U� SN���[����1ċW�m��7��c�o��&�N�i7-�T��'���Q�tz�x+�R�)�/�H��� 呲呲呲呲[�"LID��[��ͨ0%�N|��@f�<code>J:�v�P���N�E�&��/ ��E��"��v4*8�[����4��4�5Q�g����ב+��$J9䢺�C�-4h��Y�|ыGI�/�� �R'�a7(�%R��l�:�v�]y$I���w�1 �Iۮy�Ǿ/�͞iW|o�.�x,�e��5����c%ak��ra4�)��z�[f�#^#xE�'�7�;��W)V�����ӡޛ�!�=U� SN���[����1ċW�m��7��c�o��&�N�i7-�T��'���Q�tz�x+�R�)�/�H��� 呲呲呲呲[�"LID��[��ͨ0%�N|��@f�<code>J:�v�P���N�E�&��/ ��E��"��v4*8�[����4��4�5Q�g����ב+��$J9䢺�C�-4h��Y�|ыGI�/�� �R'�a7(�%R��l�:�v�]y$I���w�1 �Iۮy�Ǿ/�͞iW|o�.�x,��y��6lذa�&gt;u{�bc�G;��6<�(�����Wխ��N�M���cWⓚX���~�x[�:Ļ�q�xW��hkuM�FX��K�k ���/�5vC�^?��? �˚�8Ͼ��DU��E)F����n���������3 �G��JةlPQ�z[�9",w�B�Qu���|�4�%Բr:{��*�����T���l����9'>p���MT�$S�5��K6Vj��r�����X�����\ˎLJ�x���a%6+M�V��(�Qsj�Db�����!$��]a f�,�m���9N���������ר�&�� f o��x>T�aE�����K'nǔ�ɦ��2v1�5��"N"<ŋ��i�1��*b�9�F�\Hx��u�V"��E�j��Y����d�F�o(I滦��� �s���"�(ن��Ju� ��j h?y��^�k�~�"�������ؾ�"�H Ah�k���1y]�@]Qu�x��7_�ӹ�=

还有更多的输出,发布时间太长了。

我不知道发生了什么:/任何帮助将不胜感激。

4

1 回答 1

2

如果您正确复制粘贴代码,那么您的代码中有前导空格:

            <?php
^^^^^^^^^^^^

去掉它; 否则,空白将成为 PNG 输出的一部分,因此会导致“损坏”的图像。

编辑

现在您已经发布了完整的代码:您正在将 PHP 代码与图像的二进制数据混合;它不是那样工作的。将生成图像的代码移动到单独的文件中,例如article-image.php,然后在指向该文件的主 HTML 中添加图像标签,例如:

<img src="article-image.php?id=1">
于 2013-03-20T05:29:13.330 回答