• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

PHP ignoring typecast through class

aximbigfan

New Member
Joined
Oct 15, 2006
Messages
847 (0.12/day)
Location
St. Louis, MO
System Name QUAD1
Processor Intel Core i7 920
Motherboard Asus P6T SE
Cooling XIGMATEK HDT-S963
Memory OCZ 3 X 1GB Triple Channel
Video Card(s) HIS Radeon HD4670 IceQ
Storage Seagate 250GB 7200RPM SATA
Display(s) Acer AL1916W 19" Widescreen LCD
Case CM Storm Scout
Audio Device(s) Onboard
Power Supply Corsair 520 Watt
Software Windows XP Pro
I have a code layout with a class. In that class is a function that must return either a string or an integer. The problem is that even when (int) is used in front of the variable to return, the return is ALWAYS a string.

Any ideas? The function works just fine on i's own.

Thanks,
Chris
 
I have a code layout with a class. In that class is a function that must return either a string or an integer. The problem is that even when (int) is used in front of the variable to return, the return is ALWAYS a string.

Any ideas? The function works just fine on i's own.

Thanks,
Chris

pm me
 
You got mail.

Thanks!

Chris
 
While Pm'ing is great, people cannot see the solution to your problem.
Please post the solution here when you resolve the problem.
 
There was no solution. He tried, but we couldn't solve it.

Unless someone can figure out whats going on here, I'll assume it is a bug in PHP and needs to be reported.

Chris
 
CAn you post a little code, so we can see what you are trying to do?
 
do you have updated php with all functions avaliable and all like xeon and stuff like that.
 
As far as I know PHP is a loosely typed language in that there is only one data type, "var"...
 
There are many data types. $str $int $vchar ....ie.

The question is this class file pulling from a database? It could be that the database field is setup to be a string.

Either way something as simple as this can do string to int conversion.
<?php
$str = "10";
$num = (int)$str;
if ($str === 10) echo "String";
if ($num === 10) echo "Integer";
?>
 
Back
Top