1

文字列(PHP変数に保持されている)から画像を作成しようとしているGD/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>

そしてここに出力があります:

�PNGIHDR����PLTE������������������������������������������ �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� �������������������������������������������������� ������������������������=IDATx��X��44�、�BB@�����'��K]G��53 /Qa�-�Q]]��;MÆ6lذaÆ6lذaÆ6�S�/�����)��、����z�z_�Ό��H�&lt;�3�rc��w!|=�m�>n��� n�x��As�9�uxֈ�M?�����R&ۃ�、-o�}}��3��˚�8Ͼu��M�e���+�9��� ' �r����&��/0j-�����L_3�zW�QN�;�f#��t�x����D$Ž�&lt;�(�#�&lt;� 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�&amp; ��/��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���� ����a�W��u�[�"LID��[��ͨ0%�N|��@f�<コード> J:�v�P���N�E�&amp;��/ ��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���� ����a�W��u�[�"LID��[��ͨ0%�N|��@f�<コード> J:�v�P���N�E�&amp;��/ ��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�〜�"�����ؾ�"�HAh�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 に答える