Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

This is why I hate PHP

17 views
Skip to first unread message

Bint

unread,
Sep 8, 2012, 4:57:05 PM9/8/12
to
Can someone tell me why this does not work:

$myBool = imagecopyresized( $tim, $im, 0, 0, $F['mapx'], $F['mapy'],
256, 192, $Fwidth, $Fheight);

And even this does not work:

settype($F['mapx'],"integer");
settype($F['mapy'],"integer");
$myBool = imagecopyresized( $tim, $im, 0, 0, $F['mapx'], $F['mapy'], 256,
192, $Fwidth, $Fheight);


I have to do this instead to get it to work:

$stupidintx = $F['mapx'];
$stupidinty = $F['mapy'];
settype($stupidintx,"integer");
settype($stupidinty,"integer");

$myBool = imagecopyresized( $tim, $im, 0, 0, $stupidintx, $stupidinty,
256, 192, $Fwidth, $Fheight);


Can you not set the type for a construct like $F['mapx']?

Thanks
B

Jonathan N. Little

unread,
Sep 8, 2012, 5:19:40 PM9/8/12
to
Must be something else at play

<?php
$array_of_strings=array('foo' => '3');

// confirm element is indeed a string
echo gettype($array_of_strings['foo']); // prints "string"

// can use intval()
echo gettype(intval($array_of_strings['foo'])); //prints "integer"

// or settype() which works for me.
if( settype($array_of_strings['foo'], 'integer'))
{
// this one fires...
echo 'Successfully converted to ' . gettype($array_of_strings['foo']);
}
else
{
echo 'Failed! Element still ' . gettype($array_of_strings['foo']);
}

?>


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Bint

unread,
Sep 8, 2012, 5:41:27 PM9/8/12
to
I don't know man, I didn't change anything else. If I pass $F['mapx'] as an
argument to imagecopyresized, even if I've explicitly set it to type
integer, it does not seem to get the value. I had to use an intermediate
variable to get it to work. You say it must be something else, but if that
is the only thing I changed what else could it be?

B


On 9/8/12 4:19 PM, in article k2gcqb$m65$1...@dont-email.me, "Jonathan N.

Jonathan N. Little

unread,
Sep 8, 2012, 6:08:11 PM9/8/12
to
Bint wrote:
> I don't know man, I didn't change anything else. If I pass $F['mapx'] as an
> argument to imagecopyresized, even if I've explicitly set it to type
> integer, it does not seem to get the value. I had to use an intermediate
> variable to get it to work. You say it must be something else, but if that
> is the only thing I changed what else could it be?

What happens when you use intval() instead where it doesn't change
$F['mapx'] but just the return value of the function:

$myBool = imagecopyresized( $tim, $im, 0, 0, intval$F['mapx']),
intval($F['mapy']), 256, 192, $Fwidth, $Fheight);

digit1001

unread,
Sep 14, 2012, 2:19:55 AM9/14/12
to
Would this work...
$myBool = imagecopyresized( $tim, $im, 0, 0, (int)$F['mapx'], (int)$F['mapy'], 256,
192, $Fwidth, $Fheight);

V

unread,
Apr 1, 2023, 4:23:56 AM4/1/23
to
You seen this: https://youtu.be/IPXIgEAGe4U ?
0 new messages