开发者

Strange php behaviour on a gd function

开发者 https://www.devze.com 2022-12-27 05:45 出处:网络
i met a very strange PHP behaviour, i don\'t understand why it behaves like this. I\'m using the imagesetbrush function in this way:

i met a very strange PHP behaviour, i don't understand why it behaves like this. I'm using the imagesetbrush function in this way:

class foo
{
   function setbrush($image)
   {
       //$this->_resource contains the main image resource
       imagesetbrush($this->_resource, $image);
   }
}
...
$res=imagecreatefrompng("image.png");
$class->setbrush($开发者_StackOverflow社区res);

in this way it works, but if i change the code like this:

class foo
{
   function setbrush($image)
   {
       $res=imagecreatefrompng($image);
       imagesetbrush($this->_resource, $res);
   }
}
...
$class->setbrush("image.png");

it doesn't work anymore. Do you see some error? It doesn't show me any message it simply doesn't execute the function.


Could it be that the reference to the variable $res disappears after the function call? Have you tried declaring it as a class variable, just like the $_resource variable?


Maybe somewhere in your foo class the working directory changes, so it can no longer find the image.png maybe when opening //$this->_resource contains the main image resource

0

精彩评论

暂无评论...
验证码 换一张
取 消