Just Say "Hello" for you

How to Declare a Variable

Sunday, October 6, 20135comments


koebanget.blogspot.com - On this post I will try to explain how to declare variables using the data types that have been described in previous posts . For those who forgot what the previous post can be read a post that contains a description of the types of data that exist in php .

Php variable declaration has the following rules

Variable declaration begins with a $ sign .
Php variable names can only be numbers , letters , and underscore sign ( _ ) .
Variable names can only start with a letter , and the underscore character . Examples of valid variable name : $ i , $ _aku . Examples of invalid variable names are $ 123 , $ i +123 , +123 U.S. dollars .
Declaration of PHP variables are case sensitive , which means writing using uppercase and lowercase letters are distinguished . Examples of I $ and $ I is considered by php as two different variables .
Here is an example of a variable declaration using the types of data that exist in php

integer

Examples of the type integer variable declaration is as follows

$ bilangan1 = 123 ;
$ bil_bulat = 345 ;
$ bil3 = 567 ;
Note the above three variables are all integers store . PHP will consider three variables are variables of type integer , because these three variables store integers .

Floating point number or real data types

Examples of variable declarations of type real or floating point number are as follows :

$ bil_real1 = 0123 ;
$ bil_real2 = 1,858 ;
$ realku = 8,989 ;
Note that all three variables storing fractions rounded or not . PHP will assume these three variables are variables of type real , because these three variables storing fractions or decimals .

string

Instance variable declaration string data type is as follows :

$ string1 = " Fried Rice " ;
$ stringku = " This game is really good " ;
$ mystring = '123 love everything ' ;
Note the three variables . On three variables each variable value flanked by two quotation marks ( " ) or single quote ( ' ) . PHP will assume the string variable value if the value of the variable is enclosed in single quotes or double quotes .

But there was one important record that should not be forgotten lo , you can not combine single quotes with double quotes in the declaration of a variable of type string . Examples are as follows : $ mystring = '123 ' . Note the single quotes and double quotes in bold . In the variable $ mystring value of the variable begins with a single quotation mark and end with double quotes . It is not allowed in PHP . A true example for the declaration of a variable of type string is , if it starts with a single quote it must end with single quotes as well . When starting with double quotes then it should end with double quotation marks as well . For more details you can look at the instance variables and instance variables string1 $ $ mystring above .

boolean

Examples of type boolean variable declaration is as follows :

$ right = TRUE ;
$ one = FALSE ;
$ null = NULL ;
$ emptystring1 = " ;
emptystring2 = " " ;
The second variable is the variable that stores over the value TRUE , FALSE , NULL , and the empty string . As I have described in my previous post that considers php integer values ??0 , 0,0 estate values ??, NULL values ??and empty string as the value FALSE .

If you are confused about what is a NULL value , empty string , you can see the variable $ zero , $ emptystring1 , $ emptystring2 . $ zero is a variable that holds the value NULL ( remember the word NULL must be written with capital letters because PHP is a programming language is case sensitive , where the writing uppercase and lowercase letters are distinguished ) . What is meant by the empty string is a variable that stores only a pair of a pair of single quotes or double quotes . An example is the variable $ emptystring1 is a variable that holds the empty string value in the form of a pair of single quotation marks ( " ) . $ emptystring2 is a variable that holds a value of empty string in the form of a pair of double quotes ( " " ) .

That's a description of the types of data in PHP along with examples of variable declarations for each type of data. Hopefully this post can make you better understand the types of data in php and able to declare a variable according to the type of data required by you 

Share this article :

+ comments + 5 comments

November 3, 2016 at 7:52 PM

Okay, thank you, I so got knowledge.
ST3 Telkom

November 29, 2016 at 9:06 PM

Thank you for this inform.
ST3 Telkom

July 22, 2022 at 11:30 PM

สำหรับผู้ที่ชื่นชอบภาพยนตร์ และผู้ชมทุกท่าน ที่ชื่นชอบ ดูหนังใหม่ ซีรีย์ที่ชื่นชอบในการรับชมภาพยนตร์ ซีรีย์ ดูซีรีย์ออนไลน์ อัพเดทใหม่ตลอดทั้งเดือน

February 28, 2023 at 10:02 PM

เล่น เกมส์ ออนไลน์ เว็บไซต์คาสิโน ชั้นแนวหน้าที่ได้เก็บรวบรวมค่ายเกม PG ต่างๆเข้ามา ให้ผู้เล่นได้เล่นกันยังจุใจ ไม่ว่าจะเป็นเกม ไพ่บาคาร่า ใฮโล รูเล็ต เสือมังกรหรือเกมฯลฯ

pg slot ปิ้งยิ่งที่สุดแล้วก็ฝากถอนเงินในแต่ละครั้งได้ไม่มีอย่างน้อย สิทธิพิเศษสำหรับในการวางเดิมพันที่จะสามารถทำให้ทุกๆคนใกล้ PG SLOT เงินจำนวนเป็นอันมาก

Post a Comment

 
Copyright © 2011. koebanget.blogspot.com - All Rights Reserved
Template Created by Creating Website Modify by koebanget.blogspot.com