HOME | PHP Tutorial | CSS
facebook icon
AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP
PHP Tutorial

PHP forms
HTML Tutorial

CSS Tutorial

PHP Data Types


<< Previous Page
PHP Echo and Print
Next Page >>
PHP String Function
In PHP language, unlike other programming languages (C ++, Java, etc.), we do not have to declare the data type, because the PHP language automatically determines the assigned value.

PHP Variables can store data of different types.

PHP language supports the following data types:
Integer
String
Float
Array
Boolean
Object
Resource
NULL


PHP Integer, example


Integer - represents the set of integers Z = {..., -2, -1, 0, 1, 2, ...}. Variables of this type can be initialized with integers specified in decimal (base 10), hexadecimal (base 16) or octal (base 8).

Example:
$ a = 1234; // integer decimal
$ a = -123; // negative integer
$ a = 0123; // integer in octal format - the number must be preceded by a 0
$ a = 0x1AB; // integer in hexadecimal format - the number is preceded by 0x

Example:

<?php
$x = 6867;
echo $x."is ";
var_dump($x);
?>

Note: The PHP statements end with a semicolon (;).

PHP String, example


There are 3 ways to define String variables, but only 2 are commonly used:
- simple quotation marks: $a = 'This is a string';
- double quotes: $a = "This is a string";
To display the apostrophe (') within the text, it must be preceded by the backslash (\) character. The same goes for displaying the backslash (\) character.

Example:
$a = ‘Arnold once said: „I’ll be back”‘;
// Will display: Arnold once said: “I’ll be back”
The difference between the two ways is that in the second case some special characters can be inserted, and if a variable appears within the text, it will be replaced by the value contained in it.

Example:
$x = 40;
$a = "$x participants in the PHP course have registered."; // 40 participants in the PHP course have registered. The special characters that can be used are the following:
n new line (line feed)
r carriage return
t tab
\ backslash
$ the dollar sign
" quotation mark

Example:
<?php
$x = "Hello world!";
$y = 'Hello world!';

echo $x;
echo "<br>";
echo $y;

$x = 40;
$a = "$x participants in the PHP course have registered.";

echo $a
?>

Boolean

Boolean - is the simplest type of data. A Boolean variable can have only two values: TRUE or FALSE.
It can also take integer values to represent the above, 0 means FALSE, and any other integer value than 0 means TRUE. In the following examples the variable receives the value TRUE (true):
$a = TRUE; $a = 1; $a = -1;
or FALSE (false): $a = FALSE; $a = 0; $a = ""; // empty
<< Previous Page
PHP Echo and Print
Next Page >>
PHP String Function


PHP Data Types - php tutorial

3222. PHP String Functions, php tutorial
PHP String Functions php tutorial
https://www.agernic.com/php-tutorial/php-string-functions.html

2018. Learn PHP 5 Tutorial | Studytonight
Learn PHP Tutorial for beginners. We have covered every concept with simple examples to help beginners learn PHP.
https://www.studytonight.com/php/

3232. Easy Learning with "Show PHP", example of a simple php script., php tutorial
Easy Learning with
https://www.agernic.com/php-tutorial/easy-learning-with-show-php-example-of-a-simple-php-script.html

3214. First script, php tutorial
First script php tutorial
https://www.agernic.com/php-tutorial/first-script.html

1934. First script, php tutorial
First script php tutorial
http://www.agernic.com/php-tutorial/first-script.html

3219. PHP if, else and elseif Statements, php tutorial
PHP if, else and elseif Statements php tutorial
https://www.agernic.com/php-tutorial/php-if-else-and-elseif-statements.html

Your add here
PHP ucwords() function

PHP strrchr() Function

PHP strcmp() function

PHP implode() function

PHP strtolower() function

PHP print() function

PHP md5() function

PHP wordwrap() function

PHP printf() function

PHP ucfirst() function

PHP htmlspecialchars() function

PHP similar_text() function

PHP define() function

PHP ltrim() function

PHP htmlspecialchars_decode() function

PHP strtoupper() function

PHP 5 Constants
SQL BETWEEN Operator
PHP Operator Types
Learn PHP online from the basic to the advanced
CSS Border Style Width and Color
SQL IN Operator - example