Variable data type in php

Variable data type in php

  • PHP Tutorial
  • PHP | Introduction
  • PHP Full Form
  • How to set PHP development environment in windows ?
  • LAMP installation and important PHP configurations on Ubuntu
  • PHP | Coding Standards
  • PHP | Basic Syntax
  • PHP | Variables
  • PHP echo and print
  • PHP | Data Types
  • PHP | Strings
  • PHP | Constants
  • PHP | Magic Constants
  • PHP | Decision Making
  • PHP | Loops
  • PHP | Superglobals
  • PHP | Regular Expressions
  • PHP Examples

PHP Advance

  • Describe PHP Include and Require
  • PHP | Basics of File Handling
  • PHP | fopen( ) (Function open file or URL)
  • PHP fread( ) Function
  • PHP fclose( ) Function
  • PHP | fwrite( ) Function
  • PHP | Uploading File
  • PHP Cookies
  • PHP | Sessions
  • PHP Filter and Filter Constant
  • Implementing callback in PHP
  • Exception Handling in PHP

PHP Array Functions

  • PHP | Arrays
  • PHP array() Function
  • PHP | array_change_key_case() Function
  • PHP array_chunk() Function
  • PHP | array_column() Function
  • PHP array_combine() Function
  • PHP array_count_values() Function
  • PHP array_diff() function
  • PHP array_diff_assoc() Function
  • PHP array_diff_key() Function
  • PHP array_diff_uassoc() Function
  • PHP array_diff_ukey() Function
  • PHP array_fill() function
  • PHP array_fill_keys() Function
  • PHP Array Functions Complete Reference
Читайте также:  Appending to list javascript

PHP Calendar Functions

PHP Date/Time Functions

  • PHP Date and Time
  • PHP | checkdate() Function
  • PHP | date_create(), date_format(), date_add() Functions
  • PHP | date_create_from_format() Function
  • PHP | date_date_set() Function
  • PHP | date_default_timezone_get() Function
  • PHP | date_default_timezone_set() Function
  • PHP | date_diff() Function
  • PHP | date_get_last_errors() Function
  • PHP | date_isodate_set() Function
  • PHP | date_modify() Function
  • PHP | date_offset_get() Function
  • PHP | date_parse_from_format() Function
  • PHP | date_parse() Function
  • PHP | date_sub() Function

PHP Directory Functions

PHP Error

PHP Filesystem Functions

  • PHP basename( ) Function
  • PHP chgrp( ) Function
  • PHP chmod( ) Function
  • PHP chown( ) Function
  • PHP copy( ) Function
  • PHP dirname( ) Function
  • PHP disk_free_space( ) Function
  • PHP disk_total_space( ) Function
  • PHP feof( ) Function
  • PHP fflush( ) Function
  • PHP | fgetc( ) Function
  • PHP | fgets( ) Function
  • PHP | fgetss( ) Function
  • PHP | file_exists( ) Function
  • PHP file_get_contents() Function
  • PHP Filesystem Functions Complete Reference

PHP FTP Functions

  • PHP | ftp_alloc() function
  • PHP | ftp_chdir() function
  • PHP | ftp_close() function
  • PHP | ftp_connect() function
  • PHP | ftp_delete() function
  • PHP | ftp_exec() function
  • PHP | ftp_get() function
  • PHP | ftp_put() function
  • PHP | ftp_get_option() function
  • PHP | ftp_login() function
  • PHP | ftp_mdtm() Function
  • PHP | ftp_mkdir() function

PHP JASON

PHP Math Functions

PHP GMP Functions

PHP MySQLi Functions

PHP String Functions

PHP Network Functions

PHP IntlChar Functions

PHP Image Processing and GD Functions

PHP Gmagick Functions

PHP Imagick Functions

PHP ImagickDraw Functions

PHP DsDeque Functions

PHP DsMap Functions

  • PHP | Ds\Map allocate() Function
  • PHP | Ds\Map apply() Function
  • PHP | Ds\Map capacity() Function
  • PHP | DS\Map clear() Function
  • PHP | Ds\Map __construct() Function
  • PHP Ds\Map copy() Function
  • PHP | Ds\Map count() Function
  • PHP | Ds\Map diff() Function
  • PHP | Ds\Map filter() Function
  • PHP | Ds\Map first() Function
  • PHP Ds\Map Functions Complete Reference

PHP DSSequence Functions

PHP DSVector Functions

PHP DsStack Functions

PHP DsQueue Functions

PHP DsPriorityQueue Functions

PHP SPL Data structures

  • SplDoublyLinkedList in PHP
  • PHP SplDoublyLinkedList add() Function
  • PHP SplDoublyLinkedList bottom() Function
  • PHP SplDoublyLinkedList count() function
  • PHP SplFixedArray count() Function
  • PHP SplFixedArray current() Function
  • PHP SplFixedArray getSize() Function
  • PHP SplFixedArray key() Function
  • PHP SplObjectStorage addAll() Function
  • PHP SplObjectStorage attach() Function
  • PHP SplObjectStorage contains() Function
  • PHP SplObjectStorage count() Function
  • PHP SplQueue::__construct() Function
  • PHP SPL Data structures Complete Reference
  • PHP Tutorial
  • PHP | Introduction
  • PHP Full Form
  • How to set PHP development environment in windows ?
  • LAMP installation and important PHP configurations on Ubuntu
  • PHP | Coding Standards
  • PHP | Basic Syntax
  • PHP | Variables
  • PHP echo and print
  • PHP | Data Types
  • PHP | Strings
  • PHP | Constants
  • PHP | Magic Constants
  • PHP | Decision Making
  • PHP | Loops
  • PHP | Superglobals
  • PHP | Regular Expressions
  • PHP Examples
Читайте также:  Plotly express python line

PHP Advance

  • Describe PHP Include and Require
  • PHP | Basics of File Handling
  • PHP | fopen( ) (Function open file or URL)
  • PHP fread( ) Function
  • PHP fclose( ) Function
  • PHP | fwrite( ) Function
  • PHP | Uploading File
  • PHP Cookies
  • PHP | Sessions
  • PHP Filter and Filter Constant
  • Implementing callback in PHP
  • Exception Handling in PHP

PHP Array Functions

  • PHP | Arrays
  • PHP array() Function
  • PHP | array_change_key_case() Function
  • PHP array_chunk() Function
  • PHP | array_column() Function
  • PHP array_combine() Function
  • PHP array_count_values() Function
  • PHP array_diff() function
  • PHP array_diff_assoc() Function
  • PHP array_diff_key() Function
  • PHP array_diff_uassoc() Function
  • PHP array_diff_ukey() Function
  • PHP array_fill() function
  • PHP array_fill_keys() Function
  • PHP Array Functions Complete Reference

PHP Calendar Functions

PHP Date/Time Functions

  • PHP Date and Time
  • PHP | checkdate() Function
  • PHP | date_create(), date_format(), date_add() Functions
  • PHP | date_create_from_format() Function
  • PHP | date_date_set() Function
  • PHP | date_default_timezone_get() Function
  • PHP | date_default_timezone_set() Function
  • PHP | date_diff() Function
  • PHP | date_get_last_errors() Function
  • PHP | date_isodate_set() Function
  • PHP | date_modify() Function
  • PHP | date_offset_get() Function
  • PHP | date_parse_from_format() Function
  • PHP | date_parse() Function
  • PHP | date_sub() Function

PHP Directory Functions

PHP Error

PHP Filesystem Functions

  • PHP basename( ) Function
  • PHP chgrp( ) Function
  • PHP chmod( ) Function
  • PHP chown( ) Function
  • PHP copy( ) Function
  • PHP dirname( ) Function
  • PHP disk_free_space( ) Function
  • PHP disk_total_space( ) Function
  • PHP feof( ) Function
  • PHP fflush( ) Function
  • PHP | fgetc( ) Function
  • PHP | fgets( ) Function
  • PHP | fgetss( ) Function
  • PHP | file_exists( ) Function
  • PHP file_get_contents() Function
  • PHP Filesystem Functions Complete Reference

PHP FTP Functions

  • PHP | ftp_alloc() function
  • PHP | ftp_chdir() function
  • PHP | ftp_close() function
  • PHP | ftp_connect() function
  • PHP | ftp_delete() function
  • PHP | ftp_exec() function
  • PHP | ftp_get() function
  • PHP | ftp_put() function
  • PHP | ftp_get_option() function
  • PHP | ftp_login() function
  • PHP | ftp_mdtm() Function
  • PHP | ftp_mkdir() function

PHP JASON

PHP Math Functions

PHP GMP Functions

PHP MySQLi Functions

PHP String Functions

PHP Network Functions

PHP IntlChar Functions

PHP Image Processing and GD Functions

PHP Gmagick Functions

PHP Imagick Functions

PHP ImagickDraw Functions

PHP DsDeque Functions

PHP DsMap Functions

  • PHP | Ds\Map allocate() Function
  • PHP | Ds\Map apply() Function
  • PHP | Ds\Map capacity() Function
  • PHP | DS\Map clear() Function
  • PHP | Ds\Map __construct() Function
  • PHP Ds\Map copy() Function
  • PHP | Ds\Map count() Function
  • PHP | Ds\Map diff() Function
  • PHP | Ds\Map filter() Function
  • PHP | Ds\Map first() Function
  • PHP Ds\Map Functions Complete Reference

PHP DSSequence Functions

PHP DSVector Functions

PHP DsStack Functions

PHP DsQueue Functions

PHP DsPriorityQueue Functions

PHP SPL Data structures

  • SplDoublyLinkedList in PHP
  • PHP SplDoublyLinkedList add() Function
  • PHP SplDoublyLinkedList bottom() Function
  • PHP SplDoublyLinkedList count() function
  • PHP SplFixedArray count() Function
  • PHP SplFixedArray current() Function
  • PHP SplFixedArray getSize() Function
  • PHP SplFixedArray key() Function
  • PHP SplObjectStorage addAll() Function
  • PHP SplObjectStorage attach() Function
  • PHP SplObjectStorage contains() Function
  • PHP SplObjectStorage count() Function
  • PHP SplQueue::__construct() Function
  • PHP SPL Data structures Complete Reference
Читайте также:  Панель для сервера css

Источник

Data Types in PHP — Variable Types in PHP

In our prevous Chapter, we’ve learned How to create and assign variable in PHP. We’ve seen that we can store some data in a variable and that data could be any type, like it could be a number, text or anything. This different types is called Data Type in the aspect of Programming language.

In this chapter, let’s learn the different data types of PHP.

¶Data types of PHP

There are total 8 data types in PHP.

  1. Integer — Store number / numeric number to a variable. eg: $age = 28 , $number1 = 50 .
  2. Float / Double — Store decimal or floating point number to a variable. eg: $price = 200000.50 , $cgpa = 3.8 .
  3. Boolean — Store only true or false to a variable. If something valid then = true otherwise = false .
  4. String — Store text like data to a variable. eg: $name = «Jhon Doe» , $welcome_text = «Welcome to Learn PHP»
  5. Null — Null is another special data type, if nothing found to store in a variable, then it’s used. Which stores only a single value NULL or null . eg: $avatar_url = null
  6. Object — Object are actually a user defined data types, means — we can create a custom data type which will use several key:value pair data.
  7. Array — Store same types of multiple data to a variable, it could be named or indexed. eg: $marks = [10, 20]
  8. Resource — Resource is another special types. It’s actually not a data type. It stores the reference value of some values.

¶Integer

Store number / numeric number to a variable.

¶Example of Integer

¶Float / Double

Store decimal or floating point number to a variable.

¶Example of Float / Double

Let’s assume a product price has some floating point value like 100.05. So, we’ve to use floating point value to this variable.

¶String

Store text like data to a variable.

¶Example of String

$name = "Jhon Doe"; $welcome_text = "Welcome to Learn PHP"; $post_title = "Data Types in PHP - Variable Types in PHP"; $post_slug = "data-types-in-php-variable-types-in-php"; $post_description = "xxxxxx"; 

¶Boolean

Store only true or false to a variable. If something valid then = true otherwise = false .

¶Example of Boolean

Suppose, in our system, we’ve an authentication system, where user could log in or not. So, there would be two case, either user is logged in or logged out. We can handle this using boolean data type true or false .

$is_user_logged_in = true; $is_user_logged_in = false; 

¶Null

Null is another special data type, if nothing found to store in a variable, then it’s used. Which stores only a single value NULL or null .

¶Example of Null

Suppose, we’ve users in our website. When they first time register to our site, they don’t upload any image or called avatar. So, at first user image could be empty. We can use null to store at first registration.

¶Object

Object are actually a user defined data types, means — we can create a custom data type which will use several key:value pair data.

¶Example of Object

Suppose, we want to make a custom user defined data types of some specific things, then we use object like system. Object is an advanced topic, since we’ll discuss it later.

¶Array

Store same types of multiple data to a variable, it could be named or indexed.

¶Example of Array

Suppose, we want to store our list of marks in something, means — specific types of many data will be stored in a variable. Below example — $marks is an array data type variable.

¶Resource

Resource is another special types. It’s actually not a data type. It stores the reference value of some values.

¶Example of Resource

Resource is an advanced topic, since we’ll discuss it later.

¶Check Variable data type in PHP

So, we’ve learned the different data types. In our practical coding many times, we’ve to debug or test our code by checking the data type and data and PHP has a built in method or way to check that — var_dump( $variable_name )

That’s cool, right. We can easily check the data type for debug purpose.

Источник

Оцените статью