• We've upgraded our forums. Please post any issues/requests in this thread.

PHP ignoring typecast through class

aximbigfan

New Member
Joined
Oct 15, 2006
Messages
847 (0.21/day)
Likes
33
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
#1
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
 
Joined
Dec 13, 2007
Messages
2,758 (0.75/day)
Likes
465
#2
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
 

aximbigfan

New Member
Joined
Oct 15, 2006
Messages
847 (0.21/day)
Likes
33
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
#3
You got mail.

Thanks!

Chris
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#4
While Pm'ing is great, people cannot see the solution to your problem.
Please post the solution here when you resolve the problem.
 

aximbigfan

New Member
Joined
Oct 15, 2006
Messages
847 (0.21/day)
Likes
33
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
#5
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
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#6
CAn you post a little code, so we can see what you are trying to do?
 

panchoman

Sold my stars!
Joined
Jul 16, 2007
Messages
9,595 (2.52/day)
Likes
1,148
Processor Amd Athlon X2 4600+ Windsor(90nm) EE(65W) @2.9-3.0 @1.45
Motherboard Biostar Tforce [Nvidia] 550
Cooling Thermaltake Blue Orb-- bunch of other fans here and there....
Memory 2 gigs (2x1gb) of patriot ddr2 800 @ 4-4-4-12-2t
Video Card(s) Sapphire X1950pro Pci-E x16 @stock@stock on stock
Storage Seagate 7200.11 250gb Drive, WD raptors (30/40) in Raid 0
Display(s) ANCIENT 15" sony lcd, bought it when it was like 500 bucks
Case Apevia X-plorer blue/black
Audio Device(s) Onboard- Why get an sound card when you can hum??
Power Supply Antec NeoHe 550-manufactured by seasonic -replacement to the discontinued smart power series
Software Windows XP pro SP2 -- vista is still crap
#7
do you have updated php with all functions avaliable and all like xeon and stuff like that.
 

Oliver_FF

New Member
Joined
Oct 15, 2006
Messages
544 (0.13/day)
Likes
65
Processor Intel q9400 @ stock
Motherboard Lanparty P45-T2RS
Cooling Zalman CNPS-9500
Memory 8GB OCZ PC2-6400
Video Card(s) BFG Nvidia GTX285 OC
Storage 1TB, 500GB, 500GB
Display(s) 20" Samsung T200HD
Case Antec Mini P180
Audio Device(s) Sound Blaster X-Fi Elite Pro
Power Supply 700w Hiper
Software Ubuntu x64 virtualising Vista
#8
As far as I know PHP is a loosely typed language in that there is only one data type, "var"...
 
Joined
Mar 4, 2005
Messages
3,102 (0.66/day)
Likes
815
System Name TheReactor
Processor i7 6700k @ 4.95ghz - delid
Motherboard ASUS Maximus VIII Genie z170
Cooling EK EVO NIckle/Pump, 2xBlackIce GTX 240's
Memory 32GB G.Skill 3200Mhz Cas 14
Video Card(s) MSI GTX 980ti Gaming 6G
Storage Samsung 960 EVO 500GB
Display(s) HP ZR30W - 2560X1600
Case Corsiar 550
Audio Device(s) on board
Power Supply Antec Quattro 1000W
Mouse Logitech G502
Keyboard Corsair Gaming k70
Software Windows 10 Pro 64bit
#9
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";
?>