<?php

$s = "acesta este un text";
$sir = "stiu PHP stiu HTML stiu CSS";

# afisez o sectiune din sir
echo substr( $sir, 0, 4), "\n"; // stiu
echo substr( $sir, 5 ), "\n"; // PHP stiu HTML stiu CSS
echo substr( $sir, 5, -3 ), "\n"; // PHP stiu HTML stiu
echo substr( $sir, -3 ), "\n"; // CSS
 
# returnez doar un caracter din string
echo $sir{5}, "\n"; // P
echo $sir{ strlen($sir)-1 }, "\n"; // S

?>