Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

numeric values trick.

Status
Not open for further replies.

shaddow

Programmer
Mar 22, 2001
1,862
RO
I have seend to many problems when comparing numbers with string values. I always had problems to keep in mind the string to numeric conversion functions.
But no more headeche,i've tryed a method that i've used in Asp and Javascript, and it worked.
Assuming it's a page number and you have register_globals enabled ...
search.php?p=100
Code:
//no more string to number conversion function
$p*=1;
//now you can compare as a number
if($p==0) $p=1;
$p now it will represent an numerical value
now assume that some p values
1. search.php?p=
$p*=1;//$p will be 0;
2. search.php?p=askdfoa
$p*=1;//$p still will be 0;
2. search.php?p=101
$p*=1;//$p will be 101 as number;


Maybe for somone is helpfull as it was for me


________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
As i mentioned before, maybe you forgot how to use it.
I wonder how many knws or heard about type casting. I assume that most of programmers did but the others could not.

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top