2013-04-04 26 views
1

每当我试图使用功能imageflip(),它让我看到下面的消息imageflip()在PHP中未定义

Fatal error: Call to undefined function imageflip() in D:\xampp\htdocs\temp1\image_flip.php on line 6

一次,我已经叫imap_open功能,即使我已经安装了IMAP扩展并配置全部。但是,它仍然显示相同的消息。

回答

3

imageflip()仅在PHP 5.5之后可用。但是,您仍然可以自己定义它,如解释here(尽管如果您计划升级到PHP 5.5,不建议实施您的或至少更改名称以避免重复问题)。对于计算器的缘故,我会在这里粘贴代码:

<?php 

/** 
* Flip (mirror) an image left to right. 
* 
* @param image resource 
* @param x  int 
* @param y  int 
* @param width int 
* @param height int 
* @return bool 
* @require PHP 3.0.7 (function_exists), GD1 
*/ 
function imageflip(&$image, $x = 0, $y = 0, $width = null, $height = null) 
{ 
    if ($width < 1) $width = imagesx($image); 
    if ($height < 1) $height = imagesy($image); 
    // Truecolor provides better results, if possible. 
    if (function_exists('imageistruecolor') && imageistruecolor($image)) 
    { 
     $tmp = imagecreatetruecolor(1, $height); 
    } 
    else 
    { 
     $tmp = imagecreate(1, $height); 
    } 
    $x2 = $x + $width - 1; 
    for ($i = (int) floor(($width - 1)/2); $i >= 0; $i--) 
    { 
     // Backup right stripe. 
     imagecopy($tmp, $image, 0,  0, $x2 - $i, $y, 1, $height); 
     // Copy left stripe to the right. 
     imagecopy($image, $image, $x2 - $i, $y, $x + $i, $y, 1, $height); 
     // Copy backuped right stripe to the left. 
     imagecopy($image, $tmp, $x + $i, $y, 0,  0, 1, $height); 
    } 
    imagedestroy($tmp); 
    return true; 
} 

,并使用它:

<?php 

$image = imagecreate(190, 60); 
$background = imagecolorallocate($image, 100, 0, 0); 
$color  = imagecolorallocate($image, 200, 100, 0); 
imagestring($image, 5, 10, 20, "imageflip() example", $color); 
imageflip($image); 
header("Content-Type: image/jpeg"); 
imagejpeg($image); 

我还没有尝试过,并且代码是不是我的全部,但有一些技巧可以使其适应您的需求。