PHP Integer Variables

Submitted by: 

This tutorial will cover integer variables in PHP.

What is a variable?
A variable is a piece of information which holds a value. Each variable has a type and a reference name. The value of a variable will depend on the type for that particular variable.

What types can a variable be?
There are a few different basic types of variable which include;

Strings hold characters, letters, numbers and symbols in a string format (essentially a character array), Booleans hold a true or false value and Integers hold a full number.

When are integers used?
As stated above, integers are used to hold full numbers and as such are used for holding data such as; age, rounded numbers, totals. Integers are not meant to hold decimal numbers.

There are two types of integers; 32bit and 64bit. 32bit Integers can hold a maximum value of 2147483647, while 64bit Integers can hold a maximum value of 9223372036854775807.

Creating a boolean variable named 'integ':

  1. $integ;

Creating and initializing a integer variable named 'integ':

  1. $integ = 1;

Writing out our integer on-screen:

  1. echo $integ;

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.