Sunday, January 18, 2015

Lesson 07


ඔන්න ඉතින් යාලුවනේ අදත් මම ඔයාලට තවත් අලුත් පාඩම් මාලාවක් අරගෙන අවා.... 
ටික දවසක් පරක්කු උනාට සමාවෙන්න ඕනේ හොදේ හික් හික් වැඩ ගොඩ ගැහිලා තියෙන්නේ මේ දවස් වල ;)කොහොම උනත් ඉතින් ඔයාල වෙනුවෙන් පොඩි වෙලාවක් හරි අරගෙන අලුත් දෙයක් කියල දෙන එකෙනුත් මර සතුටක් තියෙන්නේ ඔයාලත් අලුතෙන් පොස්ටුවක් එනකම් මග බලාගෙන ඉන්නවා කියල දන්නවා නේ හික් හික්  ඔය මදැයි ඇදබාපුවා ඔන්න එහෙනම් පදමට බහිමු කෙලින් ම

අද මම ඔයාලට කියල දෙන්න යන්නේ php වල String Functions
කියන එක ගැන තමයි. අපි බලමු මේ String Functions වලින් මොන වගේ දේවල් ද කරන්න පුළුවන් කියල... :)
String Functions ගත්තහම ගොඩාක් තියනවා මම ඔයාලට මේකේ වැඩිපුරම use කරන ටිකක් තමයි අද කරන්න යන්නේ ඔයාලට පුළුවන් ඒ හැම Function එකක්ම try කරලා බලන්න.ඔන්න එහෙනම් මේ ටික හොදට බලාගන්නකෝ බය වෙන්න එහෙම එපා හොදේ හික් හික් :D

  • addcslashes — Quote string with slashes in a C style
  • addslashes — Quote string with slashes
  • bin2hex — Convert binary data into hexadecimal representation
  • chop — Alias of rtrim
  • chr — Return a specific character
  • chunk_split — Split a string into smaller chunks
  • convert_cyr_string — Convert from one Cyrillic character set to another
  • convert_uudecode — Decode a uuencoded string
  • convert_uuencode — Uuencode a string
  • count_chars — Return information about characters used in a string
  • crc32 — Calculates the crc32 polynomial of a string
  • crypt — One-way string hashing
  • echo — Output one or more strings
  • explode — Split a string by string
  • fprintf — Write a formatted string to a stream
  • get_html_translation_table — Returns the translation table used by htmlspecialchars and htmlentities
  • hebrev — Convert logical Hebrew text to visual text
  • hebrevc — Convert logical Hebrew text to visual text with newline conversion
  • hex2bin — Decodes a hexadecimally encoded binary string
  • html_entity_decode — Convert all HTML entities to their applicable characters
  • htmlentities — Convert all applicable characters to HTML entities
  • htmlspecialchars_decode — Convert special HTML entities back to characters
  • htmlspecialchars — Convert special characters to HTML entities
  • implode — Join array elements with a string
  • join — Alias of implode
  • lcfirst — Make a string's first character lowercase
  • levenshtein — Calculate Levenshtein distance between two strings
  • localeconv — Get numeric formatting information
  • ltrim — Strip whitespace (or other characters) from the beginning of a string
  • md5_file — Calculates the md5 hash of a given file
  • md5 — Calculate the md5 hash of a string
  • metaphone — Calculate the metaphone key of a string
  • money_format — Formats a number as a currency string
  • nl_langinfo — Query language and locale information
  • nl2br — Inserts HTML line breaks before all newlines in a string
  • number_format — Format a number with grouped thousands
  • ord — Return ASCII value of character
  • parse_str — Parses the string into variables
  • print — Output a string
  • printf — Output a formatted string
  • quoted_printable_decode — Convert a quoted-printable string to an 8 bit string
  • quoted_printable_encode — Convert a 8 bit string to a quoted-printable string
  • quotemeta — Quote meta characters
  • rtrim — Strip whitespace (or other characters) from the end of a string
  • setlocale — Set locale information
  • sha1_file — Calculate the sha1 hash of a file
  • sha1 — Calculate the sha1 hash of a string
  • similar_text — Calculate the similarity between two strings
  • soundex — Calculate the soundex key of a string
  • sprintf — Return a formatted string
  • sscanf — Parses input from a string according to a format
  • str_getcsv — Parse a CSV string into an array
  • str_ireplace — Case-insensitive version of str_replace.
  • str_pad — Pad a string to a certain length with another string
  • str_repeat — Repeat a string
  • str_replace — Replace all occurrences of the search string with the replacement string
  • str_rot13 — Perform the rot13 transform on a string
  • str_shuffle — Randomly shuffles a string
  • str_split — Convert a string to an array
  • str_word_count — Return information about words used in a string
  • strcasecmp — Binary safe case-insensitive string comparison
  • strchr — Alias of strstr
  • strcmp — Binary safe string comparison
  • strcoll — Locale based string comparison
  • strcspn — Find length of initial segment not matching mask
  • strip_tags — Strip HTML and PHP tags from a string
  • stripcslashes — Un-quote string quoted with addcslashes
  • stripos — Find the position of the first occurrence of a case-insensitive substring in a string
  • stripslashes — Un-quotes a quoted string
  • stristr — Case-insensitive strstr
  • strlen — Get string length
  • strnatcasecmp — Case insensitive string comparisons using a "natural order" algorithm
  • strnatcmp — String comparisons using a "natural order" algorithm
  • strncasecmp — Binary safe case-insensitive string comparison of the first n characters
  • strncmp — Binary safe string comparison of the first n characters
  • strpbrk — Search a string for any of a set of characters
  • strpos — Find the position of the first occurrence of a substring in a string
  • strrchr — Find the last occurrence of a character in a string
  • strrev — Reverse a string
  • strripos — Find the position of the last occurrence of a case-insensitive substring in a string
  • strrpos — Find the position of the last occurrence of a substring in a string
  • strspn — Finds the length of the initial segment of a string consisting entirely of characters contained within a given mask.
  • strstr — Find the first occurrence of a string
  • strtok — Tokenize string
  • strtolower — Make a string lowercase
  • strtoupper — Make a string uppercase
  • strtr — Translate characters or replace substrings
  • substr_compare — Binary safe comparison of two strings from an offset, up to length characters
  • substr_count — Count the number of substring occurrences
  • substr_replace — Replace text within a portion of a string
  • substr — Return part of a string
  • trim — Strip whitespace (or other characters) from the beginning and end of a string
  • ucfirst — Make a string's first character uppercase
  • ucwords — Uppercase the first character of each word in a string
  • vfprintf — Write a formatted string to a stream
  • vprintf — Output a formatted string
  • vsprintf — Return a formatted string
  • wordwrap — Wraps a string to a given number of characters


      අම්මෝ කොහොමද නිකම් පිස්සු වගේ නේද හික් හික් :P  
      මේකේ හැම එකකම ලින්කුවක් තියනවා ඕනේ අය ගිහින් example තියනව කරලා බලන්න හික් හික්..... 
       
      අපි දැන් බලමු මේකෙන් නිතරම use වෙන ඒවා මොනවද කියල (නිතරම කිව්වට ඉතින් මේ ඔක්කොම වගේ use වෙනවා හික් හික් )

      මම අද ඔයාලට මෙන්න මේ ටික කියල දෙනවා 
       
    • PHP strlen() function

    • PHP str_word_count() function

    • PHP strrev() function

    • PHP strpos() function

    • PHP str_replace() function

    • PHP strtolower() Function

    • PHP strtoupper() Function

    එහෙනම් ඉතින් මුලින් ම බලමු PHP strlen() function එක ගැන මේක අපි use කරන්නේ string එකක length එක එහෙම නැතිනම් දිග කොචරද කියල මැනගන්න. strlen() function එකෙන් අපි ලියන හැම letter එකක් වගේම Space උත් calculate කරනවා  එහෙනම් කස්ටියම notepad එකක් අරන් මේ code එක ලියල run කරලා බලන්නකෝ වැඩේ ඇත්ත නේද කියල 

    
    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    echo strlen("I Love PHP Coding!");
    
    ?> 
     
    </body>
    
    </html>
    
    
    

    result එක විදියට ඔයාලට 18 කියල එන්න ඕනේ හික් හික් ඇත්තද කියල බලන්න කම්මැලි කම යන්නත් එක්ක ගැනල බලන්නකෝ space උත් එක්ක හොදේ හික් හික් ;)

    ඊළගට අපි බලමු PHP str_word_count() function එක ගැන
    මේ function එකෙන් කරන්නේ අපි ලියන string එකේ තියන words එහෙමත් නැත්තම් වචන කියල තියනවද කියල calculate කරලා අපිට කියන එකයි බලන්නකෝ ඇත්ත ද මේ කියන්නේ කියල 
    මේක try කරලා බලන්නකෝ කස්ටියත් එක්කම එහෙනම්


    
    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    echo str_word_count("Welcome to My PHP Blog!");
    
    ?> 
     
    </body>
    
    </html>
    
    
    
     
    result එක විදියට ඔයාලට 5 කියන එක එන්න ඕනේ (ගැනල බලන්නකෝ වචන 5ක් තියනව හික් හික් ... :)


    ඊටපස්සේ අපිට බලන්න තියෙන්නේ PHP strrev() function එක ගැන 
    මේ function එක use කරන්නේ අපි අපි ලියන string එකක් අනිත් පැත්ත හරවල පෙන්නන්න හික් හික් බලන්නකෝ එහෙනම් මේකත් ගහල.

    
    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    echo strrev("Welcome to My Blog!");
    
    ?> 
     
    </body>
    
    </html>
    
    
    

      Answer එක මෙන්න මෙහෙම එන්න ඕනේ හොදේ හික් හික්....

    "!golB yM ot emocleW"  කොහොමද නිකම් අන්ඩර දෙමළ වගේ නේද හික් හික් ;)
    කස්ටියතව තව ඒවා try කරලා බලන්නකෝ හික්ස්.. :P

    අපි ඊළගට බලමු PHP strpos() function එක ගැන, මේ function එක අපි use කරන්නේ අපිට අපි ලියන string එකේ තියන මොකක්හරි text එකක් search කරන්න ඕනේ නම් අපි මේ function  එක use කරනවා හොදට තේරෙයි මේ code එක කරලා බැලුවහම 

    
    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    echo strpos("Hello Welcome to My PHP World!", "PHP");
    
    ?> 
     
    </body>
    
    </html>
    
    
    


    result එක විදියට ඔයාලට එන්න ඕනේ 20 කියන එක.
    :O හැබැටම කොහොමද මේ 20 අවේ දැන් ඔයාලට ප්‍රශ්නයක් ඇති 

    එහෙනම් ඉතින් මෙන්න විසදුම හික් හික් ... ;) 
    අපි ලියපු code එකේ string එකට පස්සේ , "PHP" කියල තියනවා ඒ කියන්නේ අපි ලියපු string එකේ  PHP කියල තියන තැන අපිට හොයල දෙන්න කියන එකයි අපිට අන්ස්වෙර් එක විදියට 20 එන්නේ PHP කියල තියෙන්නේ 20 letter එකට පස්සේ නිසයි ගැනල බලන්නකෝ හික් හික්



    ඊළගට අපිට බලන්න තියෙන්නේ  PHP str_replace() function එක ගැන,මේකේ කරන්නේ අපි ලියන string එකේ අපිට කොතන හරි වෙන string එකකින් replace කරන්න ඕනේ නම් මේ function එක use කරලා අපිට පුළුවන් ඒ වැඩේ කරගන්න බලන්නකෝ එහෙනම් මේකත් කරලා 


    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    echo str_replace("My", "Siripala's", "Welcome to My Blog");
    
    ?> 
     
    </body>
    
    </html>
    
    
    




    result එක විදියට ඔයාලට මෙන්න මෙහෙම එන්න ඕනේ 

     Welcome to Siripala's Blog 

    මේකේ my කියන එක වෙනුවට siripala's කියන එක replace වෙනවා හික් හික් අතල් වැඩේ නේද හික්ස් :P


     අපිට දැන් බලන්න තියෙන්නේ ගොඩාක් ලේසි function දෙකක් මේ දෙකම මම ඔයාලට එකට කියල දෙන්නම්


    PHP strtolower() Function එකෙන් කරන්නේ අපි ලියන string එකේ තියන හැම capital එකක් ම එහෙමත් නැතිනම් (Upper Case letters)  simple වලට එහෙමත් නැතිනම් (Lower Case) වලට හරවනවා

     

    PHP strtoupper() Function එකෙන් කරන්නේ අපි ලියන string එකේ තියන හැම Simple එකක් ම එහෙමත් නැතිනම් (Lower Case letters)  Capital වලට එහෙමත් නැතිනම් ( Upper Case) වලට හරවනවා

     

    බලන්නකෝ මේ example දෙක

    PHP strtolower() Function 

    
    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    echo strtolower("I LOVE PHP")."</br>";
    
    echo strtolower("welcome to my BLOG!");
    
    ?>
       
    </body>
    
    </html>
    
    
    




    result එක මෙහෙම එන්න ඕනේ 

    "i love php
    welcome to my blog!"


    PHP strtoupper() Function


    
    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    echo strtoupper("I love PHP")."</br>";
    
    echo strtoupper("welcome to my BLOG!");
    
    ?> 
     
    </body>
    
    </html>
    
    
    


    result එක මෙහෙම එන්න ඕනේ 

    "I LOVE PHP
    WELCOME TO MY BLOG!"
     


    කොහොමද එළකිරි වගේ වැඩ නේද හික්ස් කස්ටියටම හොදට තේරෙන්න ඇති අද අපි කරපු lesson එක නේද ඉතා සරල පාඩමක් තමයි අපි අද කරේ. කස්ටිය ඔය මම දීල තියන අනිත් function ටිකත් හෙමිට නිවාඩු පාඩුවේ ඔක්කොම try කරලා බලන්න ඔයලද ලොකු knowledge එකක් එනවා එතකොට කරලා බලල මොනවා හරි අව්ලක් තියනවනම් මගෙන් අහන්නකො යාලුවනේ 

    එහෙනම් ඉතින් දැන් මට යන්න වෙලාව හරි ගොඩාක් රෑ වෙලත් එක්ක හික් හික් බයෙත් බෑ ලොල් :P

    එහෙනම් කස්ටියම හොදට කියල දීපු පාඩම් ටික කරන්න 
    එහෙනම් ඉතින් හැමෝටම සුබම සුබ රාත්‍රියක් වේවා!!!

    මතක ඇතුව යනකොට කොමෙන්ටුවකුත් දාලම යන්න හොදේ.......

    එහෙනම් අදට මම ගියෝ.............................
    :) හික් හික්










    Monday, January 12, 2015

    Lesson 06

    ඔන්න යාලුවනේ අදත් මම ඔයාලට තවත් php පාඩම් මාලාවක් අරගෙන අවා. දැන් ඉතින් හැමදේම අලුත් වෙලා වෙනස් වෙලානේ නේද හික් හික්..  බලමුකෝ ඔහොම යනකොට මොනවා වෙයිද කියල හික් හික් :P

    අද අපි පටන් ගන්න යන්නේ අන්තිමට නවත්තපු තැනින් ඔයාලට මතක ඇතිනේ අපි කලින් පාඩමේ කියල දීපු ටික. අද ඉතින් බලමු එතනින් එහාට අපිට කරන්න තියන දේවල් මොනාද කියල.අද අපිට කතා කරන්න තියෙන්නේ Array කියන එක ගැන තමයි. බලමු මේ  Array එකක් කියන්නේ මොකක්ද කියල. 

    Array එකකින් අපිට පුළුවන් එක variable එකක values ගොඩක් store කරන්න. හරියට නිකම් අපි එක බෑග් එකකට එක එක දේවල් ගොඩක් දානවා වගේ වැඩක් Array එකකට අපිට ඕනේ තරම් values add කරන්න පුළුවන්. එහනම් ඉතින් කස්ටියම මෙන්න මේ code එක ගහල බලන්නකෝ අතටම මේක වැඩ කරනවද කියල 

    
    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    $test = array("I","Love","PHP");
    
    var_dump($test);
    
    ?>  
    
    </body>
    
    </html>
    
    
    


    එහනම් ඉතින් බලන්නකෝ මෙන්න මේක එනවා නේද කියල 

    array (size=3)
      0 => string 'I' (length=1)
      1 => string 'Love' (length=4)
      2 => string 'PHP' (length=3)

    කොහොමද එළකිරි වගේ වැඩ නේද ? 
    ඔයාලට පුළුවන් තව variables define කරලා දාල බලන්න 
    උදා:-   
    •  $Animals = array("Dog", "Cat", "Elephant", "Fish", "Camal");
    • $Cars= array("Benz", "Toyota", "BMW", "Honda", "Ford");
    මේවා දල try කරලා බලන්න ඔයාල එතකොට හොදටම ථෙරෙඉ ඔයාලට :) හික් හික් ඉතා සරලයි නේද 

    අපිට ඊලගට බලන්න තියෙන්නේ Object කියන data type එක ගැන 
    මොකක්ද මේ object එකක් කියන්නේ එහෙනම් ඉතින් මේක කියවගන්නකෝ   

    • "An object is a data type which stores data and information on how to process that data." 

    • "In PHP, an object must be explicitly declared."
    අපි දැන් බලමු මේක කරන්නේ කොහොමද කියල මේවා ගැන ඉස්සරහට object oriented වලදී සවිස්තරාත්මකව කරනවා එතකොට හොදටම තේරෙයි මේවා :)

    එහෙනම් කස්ටිය මේ code එක කොටලා බලන්නකෝ මොකද වෙන්නේ කියල




    
    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    class Car 
    
    {
        function Car() 
    
        {
            $this->model = "BMW X3";
        }
    }
    
    // create an object
    
    $bmw = new Car();
    
    // show object properties
    
    var_dump($bmw->model) ;
    
    echo $bmw->model;
    
    ?>
    
    </body>
    
    </html>
    
    
    
    


    result එක මෙන්න මෙහෙම එන්න ඕනේ.

    string 'BMW X3' (length=6)
    
    BMW X3 

    එනවනම් ඉතින් වැඩේ ගොඩ හික් හික්. :P

    දැන් අපිට කතා කරන්න තියෙන්නේ NULL කියන එක ගැන null කියන්නේ මුකුත් න කියන එකයි 
    මේ ටික බලන්නකෝ ඔයාලට හොදට තේරුම් ගන්න පුළුවන් 

    • Null is a special data type which can have only one value: NULL.
    • A variable of data type NULL is a variable that has no value assigned to it.
    • If a variable is created without a value, it is automatically assigned a value of NULL.
    • Variables can also be emptied by setting the value to NULL
    එහෙනම් ඉතින් බලන්නකෝ මේ code එක run කරලා 
      
    
    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    $x = "Welcome to My PHP Blog!";
    
    echo ($x);
    
    $x = null;
    
    var_dump($x);
    
    ?>
    
    </body>
    
    </html>
    
    
    


    මෙන්න මෙහෙම result එක එයි මේකේ 

    Welcome to My PHP Blog!
    null
    


    Note:  
    $x කියන variable එකට "Welcome to My PHP Blog!" කියන එක data එක pass කරට පස්සේ අපි print කරන echo එකෙන් අපිට result එක පෙන්නනවා ඊට පස්සේ අපි $x කියන variable එකට null කියල pass කරහම අපිට var_dump එකෙන් පෙන්නනවා null කියල Output එක 




    අන්තිමට අපිට කතා කරන්න තියෙන්නේ Resource කියන එක ගැන ඇත්තටම මේක data type එකක් කියල  කියන්න බෑ මේකෙන් කරන්නේ පිටින් තියන දේක reference එකක් විදියට functions and resources store කරලා තියාගන්න එකයි. අපි ඉස්සරහට බලමු ඒවා ගැන

    ඔය තමයි අපිට php වල ඉගෙනගන්න තියන data types ටික ඉස්සරහට බලමු අපි තව ගොඩාක් දේවල් තියනවා කියල දෙන්න මේ අපි කලින් කරපු හැම දෙයක් ම ඉස්සරහට use  වෙනවා එක නිසා මේ මුල තියන පාඩම් ටික හොදට බලාගන්න හැම කෙනෙක් ම එතකොට ඉස්සරහට තියන හැම දෙයක් ම අමාරු වෙන්නේ නෑ කලින් කරපු දේවල් ම තමයි කරන්න තියෙන්නේ  
    එහෙනම් ඉතින් දැන් රෑ වෙලත් එක්ක බඩත්ගිනි හික් හික්.. අයෙමත් දවසක තවත් අලුත් පොස්ටුවකිත් අරගෙන එන්නම් ඔයාල වෙනුවෙන් ම එතකන් හැමදෙනාටම සුබම සුබ රාත්‍රියක් වේවා!! ඔන්න එහෙනම් අපි කැපුනා....... හික්ස් ;)

    මතක ඇතුව කොමෙන්ටුවකුත් දාලම යන්ට හොදේ ............ 











     



    Thursday, January 1, 2015

    Lesson 05


    ලැබුවා වූ සෑම දෙනාටම සතුට සෞභාග්‍යය පිරි පැතූ පැතුම් ඉටුවෙන ලෙඩ දුක් වලින් තොර නිරෝගිමත් සුභම සුභ  අලුත් අවුරුද්දක් වේවා!! 





    ඉතින් යාලුවනේ කොහොමද? හැම කෙනෙක්ම මේ අලුත් අවුරුද්දේ අලුත් විදියට වැඩ පටන් ගන්න ලෑස්ති වෙලා ඇති නේද එහෙනම් ඉතින් ඔන්න මම අදත් ඔයාලට මේ අලුත් අවුරුද්දේ උදේ පාන්දරම අලුත් ම අලුත් php පාඩම් මාලාවක් අරගෙන අවා. හැම දෙනාම එහෙනම් මේ අලුත් අවුරුද්දේ අද ඉදන් වැඩ පටන් ගමු.


    අද මම ඔයාලට කියල දෙන්න යන්නේ php වල තියන data types ගැන අපි ගත්තොත් data types වර්ග ගොඩක් තියනවා 
    උදා:-
    • byte
    • short
    • int
    • long
    • float
    අම්මෝ තව තියනවා හික් හික්..
    මේ විදියට එක එක programming  language වලට data types තියනවා php වල අපි ගත්තොත් මේකෙත් අපිට data types ජාති ගොඩක් තියනවා...
    බලන්නකෝ එහෙනම් මෙන්න මේවා තමයි අපි php වල use කරන data types ටික හොදට ඇස් දෙක ලොකු කරලා බලන්නකෝ හික් හික්...

    • String
    • Integer
    • Float (floating point numbers - also called double)
    • Boolean
    • Array
    • Object
    • NULL
    • Resource

    අපි ඉස්සරහට බලමු මේ එක data type එකෙන් එක :)
    මේ තියන data types එකිනෙකට වෙනස් දේවල් වලට අපි use කරනවා 
    බලමු අපි මොනවටද මේ data types use කරන්නේ කියල. :)

    මුලින් ම අපි බලමු String කියන data type එක use කරන විදිය 

    කස්ටියම එහෙනම් notepad එකක් අරන් මෙන්න මේ code කෑල්ල ගහල බලන්නකෝ 

    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    $x = "Welcome To 2015.";
    
    $y = 'Happy New Year!!';
    
    echo $x;
    
    echo "<br>";
    
    echo $y;
    
    ?>
    
    </body>
    
    </html>
    
    
    


    බලන්නකෝ මෙන්න මෙහෙම output එකක් එනවද කියල එහෙනම් ඉතින් වැඩේ ගොඩ




    Welcome To 2015.

    Happy New Year!!

    ඇත්තටම මොකක්ද මේ String වලින් කරන්නේ?
    String කියන්නේ Charactors ගොඩක එකතුවක් ඒ කියන්නේ අපි වචනයක් ලියනවා වගේ වැඩක් තමයි අපිට පුළුවන් string use කරලා text එකක් ලියාගන්න වැදගත් ම කරනවා තමයි string එකක් ලියනකොට "double quote"  හරි 'single quote' හරි ඇතුලේ තමයි ලියන්න ඕනේ.

     අපි දැන් බලමු Integer කියන data type එක use කරන විදිය,
    Integer use කරනකොට ඔයාල මෙන්න මේ දේවල් ටික ගැන දැනුවත් වෙලා ඉන්න ඕනේ. එහෙනම් ඉතින් හොදට බලාගන්නකෝ... :D

    An integer is a whole number (without decimals).  It is a number between -2,147,483,648 and +2,147,483,647.
    Rules for integers:

    • An integer must have at least one digit (0-9)
    • An integer cannot contain comma or blanks
    • An integer must not have a decimal point
    • An integer can be either positive or negative
    • Integers can be specified in three formats: decimal (10-based), hexadecimal (16-based - prefixed with 0x) or octal (8-based - prefixed with 0)



    එහෙනම් ඉතින්
    මෙන්න මේ code කෑල්ල ගහල බලන්නකෝ 


    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    $x = 2015;
    
    var_dump($x);
    
    ?>  
    
    </body>
    
    </html>
    
    
    




    මේකේ output එක විදියට ඔයාලට මෙන්න මෙහෙම එන්න ඕනේ.




    int 2015
    


    මේකේ මේ var_dump කියන්නෙත් print එකක් දෙන විදියක් ම තමයි,
    var_dump වලින් අපිට පුළුවන් අපි දීපු value එක අයිති data type එක බලාගන්න ඒ වගේම අපි දීපු value එකත් බලාගන්න පුළුවන්. :)



     
    අපි දැන් බලමු Float data type එක ගැන,
    මේ code එක එහෙනම් ගහල බලන්නකෝ,
     
     
     
    
    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    $x = 2015.01;
    
    var_dump($x);
    
    ?>  
    
    </body>
    
    </html>
    
    
    



    මෙන්න මෙහෙම result එක එන්න ඕනේ 


    float 2015.01 




    float වලින් අපිට පුළුවන් ඕනෙම දශම ගානක් use කරලා අපේ වැඩ වලට භාවිතා කරන්න 










    ඊළගට ඉතින් අපිට තියෙන්න Boolean, මේකේ අදහස True ද එහෙමත් නැතිනම් False ද යන්යි
    මේ code එක එහෙනම් ගහල බලන්නකෝ,
     

    
    <!DOCTYPE html>
    
    <html>
    
    <body>
    
    <?php
    
    $x = true;
    
    $y = false;
    
    var_dump($x);
    
    var_dump($y);
    
    ?>  
    
    </body>
    
    </html>
    
    
    



    result එක එන්න ඕනේ මෙන්න මෙහෙම


    boolean true
    
    boolean false


    ඉතුරු data types ටික ඉදිරි පාඩමේදී කියල දෙන්නම් ඔයාලට :) 

    හික් හික්  අම්මෝ දැන් නම් යන්න වෙලාව හරි වැඩ ගොඩ ගැහිලා තියෙන්නේ අයෙමත් දවසක ඔයාලට තවත් අලුත් පාඩම් මාලාවක් අරගෙන අයෙමත් එන්නම් එහෙනම් ඉතින් හැමෝටම සුභ නව වසරක් වේවා!!!
    ගිහින් එන්නම් ටටා..... හික්ස් :P





    මතක ඇතුව කොමෙන්ටුවකුත් දාලම යන්න හොදේ..... :)