Home arrow PHP arrow Page 3 - Reconsidering PHP variables

Checking variable types - PHP

Php helps you to quickly build big applications and many times, its easy to neglect the security matter. Its easy to believe that security breaches could not happen to your software. But what if it does happen? For this reason, security in your applications should be kept in consideration from the beginning.

TABLE OF CONTENTS:
  1. Reconsidering PHP variables
  2. Counting your cookies?
  3. Checking variable types
  4. A Method to your madness
  5. Its the size that matters
  6. Pssst... Whats the password?
  7. And in Conclusion...
By: Iulian Turnea
Rating: starstarstarstarstar / 45
January 10, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Lets now move on to variable types.  In other words, check the variable content to find if it is numeric or string type.  For example:

<form>
<INPUT name=somevar type=radio value=1>
<INPUT name=somevar type=radio value=2>
</form>
 
The somevar variable is numeric. And if you have:
 
<form>
<INPUT name=somevar type=radio value="1">
<INPUT name=somevar type=radio value="2">
</form>

The somevar variable is a string.  Please note the importance of quotes.

You can check whatever is a string or an integer using is_integer(value) function that returns true if value is an integer.  For example:

If (!is_integer($somevar)){
echo (" Hacking Attempt ");
exit;
}

It is quite common to assign small integer values to your variables in a form. In this case, it is useful to check if your variable is an integer or a string. However, please notice that all variables sent using GET method are strings unlike variables sent using POST method that can be either strings or integers.



 
 
>>> More PHP Articles          >>> More By Iulian Turnea
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: