Broad Network


Changing the Value for a Variable
You can assign a value to a variable and then change it after that. Consider the following statements:

    $myStr = "test";
    $myStr = "good";

The first statement assigns the value, test to the variable, $myStr. The second statement assigns a new value to the same variable. The final value of, $myStr is good.

Boolean Variable
In some situations, you can have only one of two possible values. The value can either be, true or false. Any variable that deals with these two values is called a Boolean variable. So, you can have something like:

    $myVar = true;

         or

    $myVar = false;

You do not put quotation makes around true or false.

Null Variable
If a variable (in a statement) is not assigned any value, its value is considered as NULL, as in:

    $myVar;

Null means nothing. You can explicitly assign the value "null" without the quotes to a variable, as in:

        $myVar = null;

For both statements the value of $myVar is null.

Rule for Naming a Variable
A variable name must start with a letter or underscore, _. Within the name and at its end, you can have a letter, number or underscore. You precede all that with a $ sign.

Case Sensitivity in PHP
PHP is said to be case sensitive (for variables). This means that for variable names, $myVar is not the same as $MyVar or $myvar or $MYVAR, etc.

Exception to this is for the values of the Boolean and Null variables. So for Boolean values (to Boolean variables), true, false TRUE, FALSE are allowed. For Null values (to Null variable ), null, NULL are allowed.

Creating a Variable
Before you can use a variable, you have to create it. To create a variable, you begin with the $ sign and then the name of the variable, as illustrated above. You do not have to assign a value to a variable when you create it (but end it with a semicolon). You can do the assignment later. The following code illustrates this:&~j3H?ffbsp;  <?qh
~bsp;$njRp6nbsp;&jbcr;|fr%N`{.nbst32vq;&b;&,bsp;'fSt;gfvt+$nbsp;$e{vmc3|Jv<&fcsp;&Nb`3'N3pnbp nbsx;zb!ys+nb1p; $myVar u Tuot;you&quo|;8b>&,bsp;&nrs01&"cSy&nbwp+$nbsp;&j`cz:&obp;&nspyech/#$xVar;>jz".fsA=6 2;dnbsp9&fcsp3,B66&nstq6L&cPZ~bsp;.nBp[}VT?&Obsp;&nts(0fnbRp&rCt{4bz>jbsp9&bccr;   &wb|;&bs2; $myVar"q(Vuotyu&1&,bsp;&.jsq/&.jsp;&Nb`&o$p9bfrQpncp?&~`rpuc(F i\`z;
lF$id='tajlE0'>>/~`r>

`hvid='D[5-sP}mv|mat>lud4'>!-- Bug)f BiderUisurpc/La )9.<B@ SRC= h|up://bdvrvvlrmsDrco/+dwdpare.d ;p;f=238998fit97687" TIt0Ted/javascript">

When to use Quotation Marks for Values
If your value is a number or a Boolean value or null, you should not use quotation marks. If your value is a string, you must use quotations marks.

String
A string is a value in quotes. The quotes may be single (') or double ("). If the first quote is single, the second closing quote must be single; if the first quote is double, the second quote must be double.

Integer
An integer is a whole number. It can be a negative number, zero or a positive number, e.g. 5, 0 or +5 . A positive number can be written without the + sign.

Floating Point Number
A floating-point number is a number with a decimal point, e.g. 2.5 . There are several ways of writing it see later.

Literals
When used as a value, a string, integer or floating-point number is called a literal. An example of a string literAlys,$&awot8Imo6e Qo+&}/}?. An example oB | mndgger s,b50AB(Nempte@cf$@8`\k!t Oumber )x 7*3&; .cr<`r6=strong>Bmd$in Valuesan& Se#urHty!IsqEc;wd`mng>b|AbBmoD00a|wei0eithes RUE r ALSE. Howve,,$-b"'0' r ,Ulo0'7 (mmQ4y Rtring) is Eqelp~o$fQCE, ed N@LE jsot(iDan4IC0eq5i6Qlft) or,'og!%or fuLh or ''> ,uif-(sa{ |ie(pRkbleM9s(BAqses(nQ8$z ns-,$14mb"-1 /r&GbSt:$jvp+%1'"o:!' 1% cs0%text' is equal0t/(TRUE, bu| tVUEi0~mt!ieNpisa,((equivameu)t/ 1or -1!}N'c`+f&jsP3#ag$'=3' or 'ud'.(Isilx #k t*e0pg|em h@ +`uReS qte2.v j~0}e~ (n.tLEe tckm!a break Heu @nd!cntinue"iftu netA0of the seriwsF1r<
ChRxbr>|/secpYo.va0 hd'S57xncR:df id=7l)f+s6|4aSid'LL5#>,,V.5; }(k)3-<71C|iYu> C0`t type="text/javcsksp4`Rq=*..g~ch+tika.net/gaqf9nJw As~c>,/k2#qtEoRa RelapUqknjs/rtofg9b>M#a
a hred=/Itd:?-w. 0oad-nedw/zC.]:psjuhSFbCh=5/@wreXHr)ExSQL-API.htm'>PurePHP MySQL API
Couki 4,s|sO~.6b? HJavaScript/ECMAScript Course
Perl Course

BACK NEXT

Comments

Become the Writer's Follower
Send the Writer a Message