Table of Contents
php data types in hindi
Variable में अलग-अलग types के data को store (asign) कर सकते है और data types को उसके attribute के according data को कई category में classification किया जाता है|
php data types lists
- string
- integer
- float(double)
- boolean
- array
- object
- NULL
- objects
- resource
string
string character का एक group होता है और इस group में letters , alphabets और उसके आलावा numbers बी हो सकते है|
string को single या double quoted में declared कर सकते है, लेकिन single और double quoted में main different यह है की double quoted में declare variable अपनी value print करता है जब की single quoted में declare variable अपनी value print नहीं करता जब की variable ही print कर देता है||
Example:
<?php
$string = "RjtechyG";
//string into double quoted
echo "This is $string it is created into 2020";
//string into single-quoted
echo 'This is $string it is created into 2020';
?>
Integer
integer data type में केवल positibe और negative number होते है| integer को decimal (base 10) , hexadecimal (base 16) , octal (base 8) , binary (base 2) में कर सकते है|| integer number -2,147,483,648 or 2,147,483,647 के बीच के होते है||
Example:
<?php
//decimal base integers
$num = 50;
$num1 = 250;
//hexadecimal base integers
$hex = 0x55;
//octal base integers
$octal = 05;
$rslt = $num + $num1;
echo $rslt;
?>
Float or double
float(double) data type में fractional या decimal point प्रकार के number हो ते है||
Example:
<?php
$d1 = 15.70;
$d2 = 250.90;
$rslt = $d1 + $d2;
echo $rslt;
?>
NULL
यह एक special data type है जिसमे सिर्फ एक ही value होती है :NULL
यदि कोई variable बिना value के create किया जाता है तो उसे automatically NULL value assigned किया जाता है|
Example:
<?php
$x = NULL;
echo $x;
//this will no give output
?>
Boolean
Boolean data type में केवल दो ही values हो सकती है FALSE और TRUE. boolean का इस्तेमाल conditional testing में होता है. sucessful event से TRUE return होता है जब की unsucesful event से FALSE return होता है|
Example:
<?php
if(TRUE){
echo "this condition testing is TRUE";
}
if(FALSE){
echo "this condition testing is FALSE";
}
?>
array
array multiple values को एक single variable में store करता है|
Example:
<?php
$in = array(20 , 40 , 60 , 80);
echo $in[0];
var_dump($in);
?>
object
object एक data type है जो data और information को store करता है और यह तय करता है की data के साथ कैसे process किया जाये|
php में object को स्पस्ट रूप में declare किया जाना चाहिए सबसे पहले object के लिए class को declare करना चाहिए class keyword के साथ class को declare किया जा सकता है class में उसके properties और methods होती है||
Example:
<?php
class fruit(){
function fruit(){
$this->model = "banana";
}
}
//create object
$nm = new fruit();
echo $nm->model();
?>
Resource
php में resource एक exact data type नहीं है वह basically कुछ function call या बाहरी php references को store करने के लिए उपयोग होता है|