Search This Blog

  • ()
  • ()
Show more

Tutorial - PHP Data Types

PHP has seven data types. The seven types are: string, integer, float, boolean, array, object, and resource. String Strings ho...

PHP has seven data types. The seven types are:

  • string,

  • integer,

  • float,

  • boolean,

  • array,

  • object, and

  • resource.


String


Strings hold characters such as "a," "abc," "www.java2s.com," etc. PHP strings are case-sensitive.

Object


Objects are complex variables that have multiple values, and they can have their own functions.

Resource


Resources might be picture data, or the result of an SQL query. We should free up resources after using them.





PHP References


Reference type variables are actually pointer to the real data. Once two variables are pointing to the same data, you can change either variable and the other one will also update.

When you use the = (assignment) operator, PHP takes the value from operand two and copies it into operand one.





Syntax


To assign by reference, you need to use the reference operator (&) after the equals operator (=), giving =&.





Example




<?PHP/*from w w w . j av a2 s . com*/
$a = 10;
$b =& $a;
print $a;
print $b;

++$a;
print $a;
print "n";
print $b;
print "n";
++$b;
print $a;
print "n";
print $b;
print "n";
?>


The code above generates the following result.


Note


As of PHP 5, objects are passed and assigned by reference by default. Assigning an object variable is actually copying its object handle, which means the copy will reference the same object as the original.

References allow a function to work directly on a variable rather than on a copy

COMMENTS

BLOGGER: 5
Loading...
Name

apple,2,Article,14,At home,13,Author,14,Beauty,1,Biography,2,blackberry,1,Business,6,Cars,5,Celebrity,13,conspiraci,15,Fashion,5,galaxy,1,Gallery,1,Games,11,google,1,Hair,1,Health amp; Fitness,2,Histori,11,Home,169,HOSTING,27,HTML,7,imac,1,Image,1,iphone,1,Itcyber,7,Kuran,31,Lajme,34,Life amp; Love,1,Makeup amp; Skincare,1,mobile,5,monitor,1,Movies,2,News,5,No category,5,Photography,6,PHP,30,Poezi,24,POEZI amp; TEKSTE,2,Post,14,PROGRAMMIM,46,Relationships,1,review,6,samsung,1,Seo,7,Softvare,4,Sport,5,Sports,7,Stars,5,Tag,7,Tags,7,Tech,30,Teknologji,37,THEMES,3,Tutorials,191,Video,47,Videos,4,Vip News,2,Webhosting,67,WordPress,7,World,13,
ltr
item
Cr337: Tutorial - PHP Data Types
Tutorial - PHP Data Types
http://www.java2s.com/Tutorials/PHPImage/myResult/E/EXAMPLE_USING_REFERENCE_TYPE_VARIABLES__C335ACDABB6C979EEDB3.PNG
Cr337
https://cr337.blogspot.com/2016/03/tutorial-php-data-types.html
https://cr337.blogspot.com/
http://cr337.blogspot.com/
http://cr337.blogspot.com/2016/03/tutorial-php-data-types.html
true
5516280490839897951
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy