1. Home
  2. Computing & Technology
  3. PHP / MySQL
photo of Angela Bradley
Angela's PHP / MySQL Blog

By Angela Bradley, About.com Guide to PHP / MySQL

Function Friday: Abs () Function

Friday July 4, 2008
The Abs () Function is used to find the absolute value of a number. The absolute value is the distance a number is from zero, so the absolute value of 6 is 6, and the absolute value of -6 is also 6. The absolute value of a number is always positive.
Comments
July 30, 2008 at 7:07 pm
(1) deathisonitsway says:

to get query_string on url ,for example;

http://www.mysite.com/index.php?id=-1

this id value will in is_numeric function,however,id value is negative,then abs function will usefull here.For example; query_string id value can be mysql query for id column,then that query is returned empty.

To avoke it ;

$id=(abs($_GET['id']));

if(is_numeric($id) ) {

// process…

}

else {

echo ’sorry,not is_numeric id value’;

}

you can use such as a code that above.only note that, attacker does not strive for so a situation,nevertheless,consider it :=)

regards

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss
Community Forum
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL

©2009 About.com, a part of The New York Times Company.

All rights reserved.