PHP - String

In php you can store string in variable and directly print in echo and print function with echo used single quotes, double quotes the following simple example.

Example



<?php
	echo 'This is Simple String With Single quotes';
	echo "This is Simple String with echo and double quotes";
?>							
							

In this topic we have includes some string function for better understanding string manipulation in php the following string function and example.

Length of a String



<?php
echo strlen("veewom"); // outputs 6
?>							
							

Number of Words



<?php
echo str_word_count("Veewom"); // outputs 1
?>							
							

Reverse a String



<?php
echo strrev("Hello world"); // outputs dlrow olleH
?>								
							
Share Share on Facebook Share on Twitter Share on Google+ Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit