PHP Some String Examples – String Function

<?php
    $str = "This is a string";    $str = $str . " with some more text";    $str .= " and a newline at the end.\n";    $num = 9;
    $str = "<p>Number: $num</p>";    $num = 9;
    $str = '<p>Number: $num</p>';    $str = 'This is a test.';
    $first = $str[0];
 
    $str = 'This is still a test.';
    $last = $str[strlen($str)-1];
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.