strlen() php code example

Example 1: ucfirst() php

<?php
$foo = 'hello world!';
$foo = ucfirst($foo);             // Hello world!

$bar = 'HELLO WORLD!';
$bar = ucfirst($bar);             // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>
// string manipulation function

Example 2: how to check php string length

<?php
$name = 'abcdef';
echo strlen($str); // 6

$string = ' ab cd ';
echo strlen($str); // 7
?>

Example 3: php string length

<?php
$str = 'Hello World!';
echo strlen($str); // 12
?>

Example 4: strlen php

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

Example 5: php serialize()

php array to be storable value in $_SESSION:
 serialize($array)
  serialized array element to be output on page:
unserialize($serializedArray)

Tags:

Php Example