PHP Tutorial
- PHP Tutorial
- Install PHP
- PHP Code
- PHP Echo and print
- PHP Variable
- PHP Variable Scope
- PHP $ and $$
- PHP Constants
- PHP Data Types
- PHP Operators
- PHP Comments
Control Statement
- PHP If else
- PHP Switch
- PHP For Loop
- PHP foreach loop
- PHP While Loop
- PHP Do While Loop
- PHP Break
- PHP Continue
PHP Functions
- PHP Functions
- Parameterized Function
- PHP Call By Value and reference
- PHP Default Arguments
- PHP Variable Arguments
- PHP Recursive Function
PHP Arrays
PHP Strings
PHP Math
PHP Form
PHP Include
State Management
PHP File
Upload Download
PHP OOPs Concepts
- OOPs Concepts
- OOPs Abstract Class
- OOPs Abstraction
- OOPs Access Specifiers
- OOPs Const Keyword
- OOPs Constructor and destructor
- Encapsulation
- Final Keyword
- OOPs Functions
- OOPs Inheritance
- OOPs Interface
- OOPs Overloading
- OOPs Type Hinting
PHP MySQLi
- MySQLi CONNECT
- MySQLi CREATE DB
- MySQLi CREATE Table
- MySQLi INSERT
- MySQLi UPDATE
- MySQLi DELETE
- MySQLi SELECT
- MySQLi Order by
PHP Topics
- Compound Types
- is_null() Function
- Special Types
- Inheritance Task
- Special Types
- MVC Architecture
- PHP vs. JavaScript
- PHP vs. HTML
- PHP vs. Node.js
- PHP vs Python
- PHP PDO
- Top 10 PHP frameworks
- phpMyAdmin
- Count All Array Elements
- Create Newline
- Get Current Page URL
PHP Mail
There are 2 special data types in PHP
- Resource
- Null
Resource Data type:
It refers the external resources like database connection, FTP connection, file pointers, etc. In simple terms, a resource is a special variable which carrying a reference to an external resource.
Example 1
<?php
$conn = ftp_connect("127.0.0.1") or die("Could not connect");
echo get_resource_type($conn);
?>
output
FTP Buffer
Example 2
<?php
$conn= ftp_connect("127.0.0.1") or die("could not connect");
echo $conn;
?>
output
Resource id #2
Example 3
<?php
$handle = fopen("tpoint.txt", "r");
var_dump($handle);
echo "<br>";
$conn= ftp_connect("127.0.0.1") or die("could not connect");
var_dump($conn);
?>
output
resource(3, stream)
resource(4, FTP Buffer)
Null Data Type:
A variable of type Null is a variable without any data. In PHP, null is not a value, and we can consider it as a null variable based on 3 condition.
- If the variable is not set with any value.
- If the variable is set with a null value.
- If the value of the variable is unset.
Example 1
<?php
$empty=null;
var_dump($empty);
?>
output
null
Example 2
<?php
$a1 = " ";
var_dump($a1);
echo "<br />";
$a2 = null;
var_dump($a2);
?>
output
strring ‘ ‘ (length=1)
null
Example 3
<?php
$x = NULL;
var_dump($x);
echo "<br>";
$y = "Hello javatpoint!";
$y = NULL;
var_dump($y);
?>
output
null
null