Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Datatypes in PHP and String Functions - Tutorial 3

    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1
    • 447
    Comment on it

    Datatypes supported by PHP

    1. String
    2. Integer
    3. Floating point
    4. Boolean
    5. Array
    6. Object
    7. NULL
    8. Resource

    String Functions

    Strlen() : Returns the length of a string (number of characters).

    <?php
    echo strlen("Hello world!"); // outputs 12
    ?>
    

    Strrev() : reverses a string:

    <?php
    echo strrev("Hello world!"); // outputs !dlrow olleH
    ?>
    

    Strpos() : searches for a specific text within a string. If a match is found, the function returns the character position of the first match. If no match is found, it will return FALSE.

    <?php
    echo strpos("Hello world!", "world"); // outputs 6
    ?>
    

    str_replace() : Replaces some characters with some other characters in a string.

    <?php
    echo str_replace("world", "Dolly", "Hello world!"); // outputs Hello Dolly!
    ?>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: