`í`<, b/l9 >,  lma@abxp stùle"bes{zÏeîv-alyg6ñrl(images/top.gIf©+baCkçbou.d%SEôea6:be0met¼® 3s;‘.p> um}-å$i2`kr£(hl=ati4/ style='cglOf¿ô©dE#¾Dfíô4/C:<qPmï>H
misc| $bis Site,/#}ptolv8/Sérm>
¼q êxm,¦ht6p://www.broid juvoz/ŽWNí/i.lexl(|M>BroaddNuWwork!$ =a¤xr%n="httpº//5ww.bòoa&-netoR}.+nMéqmRgâ>(|mb hG¹/aaÅ6>eaOeá$a0_%mber 0 Loghn¸/a>$ 0& ,c izáF9"ìtd0:/+wgu.broad-network.co-/wSite.htm" id="wziôaÆp pétn%=#Write"Niyd"lf´thar i3 l@pu¤Ìl {dries2 3|yle="dI{ð\gù2o-ne":Wbk´e")mk64.@~  !=á¤xpEf½0h|up;/«www/böoe$=LDôgosk¨cgl/Loçut,h}l¦ id="ìog-utL":stle=¢di1plCù²o-.m">LkoWP<¯ý> kstrOnç.

4/Nev>M +¼/h'ader> <[bòypt typd=£te8|/EÇÉÅs’iÐ&§.  `( ` iG (eCuionPtãsagå.w0)tgC./Hn==`"~N/@n‚9 ( $ 0{O(!  0   r `( $daument/oáTAhe}wn4jyÈt¬!lwdinL').stil%fdiSpèay = "none"+MJ( 0(`$ ¤ 0àdo!5meÎt¢5U0d%EeîdByAd #øo/wU$DW#®ãôy&/HeWTxcx ¸ Æiî]ine"; 0 p(`( % ´" do!umeît.%etEleMeîdBy[d`,wjh4mN'i.sUyLa®dkspLaùp5 #mnline"» f 0#b¤ ! ¤} else if -sñqsyo.toS!çe0eaduR ç÷afB9 &lýga%#) ! ¥ ¤8 @( 0" { ø' S" ( $ „ °p0d-o}|cndlgeUElementById('DoÇ}îL'k.S|ù\e.tkspnaq!= "none;Z ` (  ($4  tocueeNp.getl}OeîôC;d('lOgïetL7©n{6yle,darplay = " näYne"?"$"¨1â´ }<wcrhp>;H <Äiöbk(Icq-%.av svydd=§dc1Xiay:inliîe- doCo; my,Méptx9”°àh;våbticáh-3nig,:|Op' ie=£nav2'> <(3 Rtyle='text-align:#eoUár'>Re|q4-l Articl%s<h3> a hrug}«IntroduotIy.e|o-PHP.htm'>Intrïdu!t)nA|O ÐPP+a><p¾-p¤class='la}&,pt3me='':>Q*éâmf]+XiT-Basmc=Qyntax.htm'>PHP Basic Syntax

Øe!IöwFu®Rcóáb1/of PHP-Referejcu,htm'¾Ba1icy0'(aJP R%feSgnkD<¯q>5/º<`cd`sS§þy~f|¼le#æ>¸ href=%P@Q-OO@-iskc{/hôm'|PHPOË@Xíuag<k>¼/pü,p<.njwX/+q.¦|p!claSsý2n@v">Bra$(Îet5ork=/´?¯<` #fa{r}bn@W ¾`âxred=*!tôUº}+wgu&jRKed-ndtão2c®Co¯mmLBaÒ.è&m">Become a MeabU|<e7<‹t¾ ~p clqs3"ëp⤿<åbxr%n="httP:¯?www.broat)/}rwo0k.com/onUece,¬tmC>CNntact<¯p¸où@áüró©"nav".nt} >AozeA¨uèU4.a>+ŠH art)clD id='A1'"süxl'='dasPha}:yl,in-æÍoc); widph*5:vW? verticad-áhé5n:topO>ŒF#Ziðd t}qe»clu;|«ECEAsgBi°l'<‚ b " 8!`(if (ses{iMj{uïbaçe.5rátE4Lofkê(<= "logan- $ 0" 1 ä( ¬y= ¬ $   'oçumentngeUAlu/QîX+KD('CÐ'k.stùleldisplay = iîtiOu"{   !`¤ !$%"´*! } 0L ‰+ $!0¦`  sessionStopaod.wripebKD0=b*:#; " (! $ 8qEfs­'îSU-rage.articleKä(¼r#3¶0¦9! (($  b¡các3)o_s0graGu®iòdNn ¹ "9 ÿ 0$0  0   b " '.ajAxŠ% þ# 0"`0(a(  vq0`Pm¬x4Utš"(0 `h( !$ 0 `(var ctsöánvUZM(9 tmcw/eNp®UPN;% Í B ´ ( $ 0 tav"hwi_l_®J]fIôd0ReXuEwt!*ˆ! p`h  `(  0 {?/b#odd ç´ ÉE·i,"FiSefox !Ã|rO/å¼ 2%[a, Safe2y+ b" (! " ¨! b " *!K!40`(xmlh|tP$=(nEs XLìQtqráñeest)» "$(¢ 0b ! ¤ h ](   j $  0 elsedh( $ 0" ( [+/ cedM%fkr0Ke2© ßF‰‚0$$ ! ¥ ¤ ` àhmMhttp = oeò`ÅcUitÅQŽ´jDbp­6Êíçxo[kfð.hMŒPTT@'i3Š b $ 0" ¦0(~M- 0@f "¤ 0 `( $x}nHtô`.onready3taUuciîwuµ&](ction() $$ 0" $ 0"  2ÿ* à0!   b! ¤ @   ig ¬8mhId60.[DAàyS6iôE$}=(5) " (` ¤ & !¤¢0(! ûb! ¤ ` (! 0 `(( $Éb jzMdédtp.st`|qS$= 2°0)O $ 2" ¡$b ñ0ä { , 1" 0 " (# (! ! ¤   â|ì  0! ¤ `  H € ! Álóu ( $  0 0!`¬ { } } } writerID = sessionStorage.writerID; articleID = sessionStorage.articleID; partNo = sessionStorage.partNo; readerID = sessionStorage.readerID; sendStr = 'writerID='+writerID+'&articleID='+articleID+'&partNo='+partNo+'&readerID='+readerID+'&articleURL='+currentURL; xmlhttp.open('post', 'http://www.broad-network.com/pageViews.php', true); xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xmlhttp.send(sendStr); document.getElementById('edit').href = "http://www.broad-network.com/edit.php?writerID=2&articleID=330&partNo=8";

(adsbyfoëglu}¨gindow.!duCdî^ãle || [U)tush({}); 4/erBql|'Eir:,j3~XHP ßp0åD{p Ba{iC÷ s+dj Sgg}cktyCî~çerls4.h5>,j2BicK%{!of PIP¥wíth Ce#}rIäùp onsidus!øko~r@ xdòt z
8§`8d>Rs+ |i hReæ'èd<0WSw®r2OiÅjetWoò{&cMi'BjòQR£þdhqrVípsb`=1oxrofcLM«xtM§¾ªrX1an4huVÄqte PubliûhE": 18 BaN$2ð18_/spen.:. ¹<Öectknf¥hd9#Sc%>>h;?Intro$ucUicf l·>asBr©ptA> ` functiol(!!{   +f (w+ndwnKHITIOC8›4}käwd'ouf) {0S)övkw>AXKIBP ý({b'õnh6÷# *"[] }; |;‰ "(÷qR ô~Ít - {2c!¤ltpe":#!÷yO`[¾œ&,QrUbîyxå‡*>({BW=q%¢ç$x+8#0p bøcH5jt":250,#såe¾"Sjithoå0Fedau-TÜ»0" var ðla!emeNtßyd 9 akvgow.CHÉTI A.units.length;  ganDkw.gÙVH É>u~i4{.ptsì(wîa5k3-*  $ogT}gnt&wRmte8'|lir yf="ãhi6Icaq`lock'¨¹€}§ã5ie_v×a@F?"'">>/ìlvl-) } ) ?*,¯#kziPpŠ,script type="text.kåòascrip4& Bpc"¯?sd>'3ä!lX/­&nev/odtads.zsb*a{xnc>¸ƒdÛ6Õxi3IÚ±@árt 8 of my s1r=Nc*Rãbiçs ïf HP widh`Ke#}ri4y0â/fÄ"áeLö(`s sOlõliOj$t"ce~tQnf¤Wasgr-|k"xsoâle/r.Ùoe"shu¬l *`vá read"p`4 pY$~hNu{ PEpôk!oj D~g`sdries before be!kjiff hErå< ár ²xl1¾cz1T(í0koNpinuetyen8bv>,`r~O0ebÀ.l>/sUrgnG;4¦R:`n peSanà y3 ñ 6+0iabld$ëba |iteral"(z`|ue!"aÿrociétE""WaÕx qn ïð%0#Uorî ŒnC+°mr$ç2ºtO"{p:$ïjfr;lnBsP)„vãcp;dmywav$-2!0ó4d<æfS?&áqwer is a leFpàorva_f qj$810 is i R|g¬| e°Mwná.¤= is the aSséwnMuî4(/x%zauKr¬0þk4zvhe0e1}Al ÿde`+|os*`TiE¤añU#®0oReúptïr +s,p?}vhen Deá|)ngWiôy!êñmbers0aì c60iNgs+0#*m0ïs$ucfd¤only!aêgonditi¯nsM2x?bonsIdåc:¸crº
&nòsq¦~bsp;&nbsð;&,"sbh-myVár damp;Aíè+ hisV`sä¢aHp+$áe`Yd,heúVA4

There arG ü}rug!oôeránd± i,bthe abmvm1%8xSgs{hon. So, you ãá.b¶@l) ïf ¶hebfirst, sachd0knF$|iird o1môàceè &&aíp;bis the,a~Â2oxära&o2& Kt(js(pl`eyAMðýu¤of a logiccl(nrEzðd/Z ¬0÷ee later.8bb<¼brl<3|rnnã>zitléetaw;zåbqt¯zb~ë{4soÛc~$`r>AN ÁbéTh¯udI#¨op%zator da+ms one or two |u%keps(`w rerand7!8ÂiuhÁr |iveJd,û"-0 fa2eAbê%k{(!fd B'´eRfsp)l¤eNsµuv,0siehda¤d bwIat lé@R£~s in arithmåti.¼rr>-b¾6tdewda.Ha¢v Arït`ldlí-oöez`toòs 'ru al%itHon ««4jRqbtraataFn€<-i, Lu,tiÑ,k!Hõim,()*9,`ind(dIòir)ëf!/©> o\a`time expnaanéêfbòhmre`foTr opezatkòC, zq{äv/`d and tòy hå0follmwaoe"mq`mplEqº$cr>=bv><1tsoëgºA d{Wann OperavoZ=¯ctRì7>=br>KjDõ"Exá}phe*>bR>¼rs>¢lt;?xhP8br~&nb{p"~`sp;&îrss3¢nbSp»4vaz19 22{4cw>¶|r{0*î@÷:*d.jvp¯4n¢yxqrar2 - s8<âb>.nBwp;&n2sp&bsP"îr1p;
fNbÂ`.|`{q; 9&bccr;$vqrs(= $var2 &¤vbS5¿
=bö¾&n sp?'è÷@<&ê`sp:jbsp;echo $v!r3bò.rr.>3to^c>[4btSacvigo Operet/püs7rëng>|crš&êfc`y/nÇst+FnâBp;ælbp; vqsq¬= 20;=bö>$njrp+&.js`»ff sx; $var2 = 30;
    
    $var3 = $var2 - $var1;
    echo $var3;

?>

Multiplication Operator
Code example:

<?php

    $var1 = 20;
    $var2 = 30;
    
    $var3 = $var2 * $var1;

    echo $var3;

?>

Note that the multiplication operator is * and not X.

Division Operator
Code example:

<?php

    $var1 = 20;
    $var2 = 30;

    $var3 = $var2 / $var1;

    echo $var3;

?>

Note that the division operator is, / .

Other operators are the Modulus (%), Increment (++), Decrement (--), and the Negation operators. You have to learn the particular way in which each of these operators behaves (see below).

Modulus Operator
The modulus operator divides the first operand by the second operand and returns the remainder. Read and try the following code:

<?php

    $var1 = 17;
    $var2 = 12;
    
    $var3 = $var1 % $var2;

    echo $var3;

?>

The Modulus operator is the percentage sign.

Increment Operator
The Increment Operator is, ++. It works with one operand, not two as the others. The operand has to be a number. When it is placed in front (prefix) of the operand, it behaves in one way. When it is placed after (postfix) the operand it behaves in another way.

Prefix: When it is prefix, it adds 1 to the operand and returns the incremented operand. Try the following code:

<?php

    $var1 = 10.5;
    
    $var2 = ++$var1;

    echo $var2;

?>

In the code, initially, 10.5 is assigned to $var1. Then we have a statement. In the statement you have a new variable, $var2, the assignment operator and then “++$var1”. What interest us here is “++$var1”, where the increment operator is in front of the variable. The value the increment operator returns is assigned to $var2. If you have tried the code, you would have noticed that the value of $var2 is 11.5. This means, if used prefix, it increments the operand and then returns the incremented operand. Note: in the above code, the final value for $var1 is 11.5 and not 10.5.

Postfix: When it is postfix, it returns the operand before adding 1 to it. The returned value is the original value of the operand. The increased value is the new value of the operand, which is not returned. Read and try the following code.

<?php

    $var1 = 10.5;
    
    $var2 = $var1++;

    echo $var2; echo "<br>";
    echo $var1;

?>

If you have tried the above code, you would have noticed that the value for $var2 is 10.5 and the final value for $var1 is 11.5, confirming that the incrementing took place after the value was returned. The “echo '<br>'” sends a line break to the console so that the next result should be displayed one line below the previous one. In PHP, you can have more than one statement in one line, such as in, “echo $var2; echo '<br>';”.

Decrement Operator
The Decrement operator, -- , behaves like the increment operator with the difference that it subtracts 1 instead of adding.

Negation Operator
This operator is the negative sign, - . It works with one operand (on its right); it negates the operand just like in math. Try the following:

<?php

    $var1 = 25;
    
    $var2 = -$var1;

    echo $var2;

?>

The NULL Value in a Condition
When a variable is declared without a value assigned to it, PHP assigns the constant value, null to the variable, without you knowing. When dealing with numbers, null is equal to zero but not identical to zero. When dealing with strings, null is equal to the empty string, "" or '', but not identical to the empty string. The identical operator is === . Try the following code:

<?php

    $var;

if ($var == 0)
    {
        echo 'null equals zero', "<br>";
    }
if (!($var === 0))
    {
        echo 'null is not identical to 0 but is equal to 0', "<br>";
    }

echo '<br>';

if ($var == '')
    {
        echo 'null equals ""', "<br>";
    }
if (!($var === ''))
    {
        echo 'null is not identical to "" but is equal to ""', "<br>";
    }

?>

The output is:

null equals zero
null is not identical to 0 but is equal to 0

null equals ""
null is not identical to "" but is equal to ""

Comparison Operators
A comparison operator compares the operands on its sides and returns a logical value (true or false) depending on whether the comparison is correct or wrong. If the comparison is correct a logical value of true is returned. If it is wrong, a logical value of false is returned. Another name for Boolean Value is Logical Value, which is either true or false.

In PHP when dealing with a value, you should consider the type of the value as well, otherwise you will get into security problems. The types of values you have learned so far are: Integer (e.g. 3), Float (e.g. 3.5), Boolean (true or false), string (e.g. 'text') and Null (has only one value, null).

The Equal Operator for Numbers
It is ==, typed as a double assignment operator. The equal operator returns true if operands (numbers) are equal, otherwise it returns false. This operator should be used when the type does not matter, otherwise use the Identical operator, === .

The Not Equal Operator for Numbers
The Not Equal operator is the opposite of the Equal Operator. The Not Equal operator is, != . It returns true if the operands are not equal, otherwise it returns false. This operator should be used when the type does not matter, otherwise use the Not Identical operator, !== .

Let us look at some examples:

Try the following code:

<?php

    $myVar = 25;
    $hisVar = 30;

    if ($myVar != $hisVar)
        {
            echo 'The values of the two variables are not equal.';
        }

?>

$myVar is 25, $hisVar is 30. The condition is read like this: If $myVar is not equal to $hisVar, even if one (variable) is of type integer and the other is of type float, then the if-block will be executed. Since the values of the variables are not equal (in value independent of type),  then ($myVar != $hisVar) returns true.

In the following code, the values of the two variables are equal, so the condition returns false and the if-block is not executed.

<?php

    $myVar = 50;
    $hisVar = 50;

    if ($myVar != $hisVar)
        {
            echo 'The values of the two variables are not equal.';
        }

?>

Note: The letter O and the digit zero are not the same things. If you type the letter O in place of zero (0) you will not have the right results. The digit zero is found in the number keypad of your keyboard. The letter O is found in the main keyboard area.

The Equal Operator for Strings
The equal operator for strings is still == . The equal operator returns true if operands (strings) are equal in characters, position of characters and respecting the corresponding casings (upper and lower case), but independent of the type, otherwise it returns false. Try the following code:

<?php

    if ('I love you.' == 'i love you')
        {
            echo 'The values are equal even though I is not i.';
        }
    else
        {
            echo 'The values are NOT equal because I and i have different casings.';
        }

?>

The Not Equal Operator for Strings
The Not Equal operator is the opposite of the Equal Operator, and it is still independent of type. The operator is != . It returns true if the operands are not equal, otherwise it returns false. Read and try the following code:

<?php

    if ('AB34E' != 'AB34E')
        {
            echo 'The values are not equal independent of type.';
        }
    else
        {
            echo 'The values are equal and type should not matter.';
        }

?>

The Greater Than Operator for Numbers
The Greater Than operator is, > . It returns true if the left operand is greater than the right operand. In the following example, the left operand is greater than the right operand. So the if-block is executed:

<?php

    $variab1 = 60;
    $variab2 = 70;
    if ($variab2 > $variab1)
        {
            echo 'The value of $variab2 is greater than the value of $variab1.';
        }

?>

Try the code.

Greater Than Or Equal Operator for Numbers
The Greater Than or Equal operator is, >= (it is the math greater than sign followed by the math equal sign). It returns true if the left operand is greater than or equal to the right operand. Try the following code:

<?php

    $variab1 = 60;
    $variab2 = 60;
    if ($variab2 >= $variab1)
        {
            echo '$variab2 is equal to $variab1, which satisfies the logic.';
        }

?>

The Less Than Operator for Numbers
The Less Than Operator is < .It returns true if the left operand is less than the right operand. Try the following code:

<?php

    $variab1 = 60;
    $variab2 = 70;
    if ($variab1 < $variab2)
        {
            echo 'The value of $variab1 is less than the value of $variab2.';
        }

?>

The Less Than or Equal Operator
The Less than or Equal operator is, <= . It returns true if the left operand is less than or equal to the right operand. Try the following code:

<?php

    $variab1 = 60;
    $variab2 = 60;
    if ($variab2 <= $variab1)
        {
            echo '$variab2 is equal to $variab1, which satisfies the logic.';
        }

?>

Security Issues

The Identical and Not Identical Operators
With comparison operators, security problems arise when dealing with == and != . == means the two operands are equal ignoring their types. != means the two operands are not equal, still ignoring their types.

If the two operands have to be equal in value and also be of the same type, then you have to use the identical operator which is === (i.e. three assignment operators).

Now, note this: If the two operands are not to be equal in value or not to have the same type or not to be equal in value and not to have the same type, then use the Not Identical Operator, which is !== .

Let us look at some examples:

The value, null is the only value of the type, null. The Boolean type has two values which are true and false. However, null is equal to false but not identical to false. A function might return the value, null, which is a valid value. You may want to test if null has been returned; but if you instead compare (by equality) it to false, you will have the wrong answer. To have the correct answer, you have to use the identical operator and compare null to null. The following code illustrates:

<?php

    $vari = null;   # returned from a function

    if (false == $vari)
        {
            echo 'This is not strict and so answer is definitely wrong.';
        }

    echo "<br>";  # send following output to next line

    if (null === $vari)
        {
            echo 'Very Correct!';
        }

?>

Try the code.

'0' and '' are each equal to false but not identical to false. '0' is a string with zero as the only character. '' is the empty string. They are both strings, but their contents (type) are not the same as false. For effective verification of '0' or '', you have to use the identical operator (and not the equal operator). Read and try the following code:

<?php

    $vari = '';   # returned from a function

    if (false == $vari)
        {
            echo 'Looks correct but comparison is wrong!';
        }

    echo "<br>";  # send following output to next line

    if ('' === $vari)
        {
            echo 'Very Correct!';
        }

?>

Replace '' with '0' in the above code and you will have the same result.

Read and try the following code which shows that '-1' is equal to true but not identical to true:

<?php

    $vari = '-1';   # returned from a function

    if (true == $vari)
        {
            echo 'Looks correct but comparison is wrong!';
        }

    echo "<br>";  # send following output to next line

    if ('-1' === $vari)
        {
            echo 'Very Correct!';
        }

?>

We have done a lot. Time to take a break. Rendezvous in the next part of the series.

Chrys

Related Links

Basics of PHP with Security Considerations
More Related Links
Pure PHP Mailsend - sendmail
PurePHP MySQL API
Using the PurePHP MySQL API
Cousins
JavaScript/ECMAScript Course
Perl Course

BACK NEXT

Comments