String in PHP

When many characters are written together in sequence, they create a string. For example, Rahul is a string. It’s made up of r, a, h, u, l characters. One string can be composed of many types of elements. You can see it as an example.

Numbers – You can take any number from 0 to 9 in a string.

Letters – A string may be composed of small letters (a – z) or capital letters (A – Z).

It’s very easy to create strings in PHP and work with them. PHP also provides some built in functions to work with strings. Let us now see how you can create strings in PHP.

You create strings in PHP just like a normal variable. Its simple syntax is being given below. You can type the string in double quotes or in single quotes.

$string-name = "string";

PHP Strings Function

PHP provides you with more than 100 built in string functions. Some of these functions are being explained by example below.

strlen()

You can get the length of any string by using this string function. This function returns the same number of charecters you have in the string. This number includes spaces too. It has been explained through an example.

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

Output
12

 

Strrev()

With this function you can show any string value in reverse order. This is being explained by the example below.

<?php 
$val = "rahul";
echo strrev($val);
?>
Output
luhar

 

Cialis (Tadalafil) är den främsta konkurrenten till Viagra (Sildenafil) på marknaden för erektil dysfunktion. köpa Cialis i Sverige föredras av många på grund av sin längre varaktighet och anses vara det mest kostnadseffektiva varumärkesbaserade ED-läkemedlet som finns tillgängligt i Sverige. Cialis finns i två varianter: Cialis och Cialis Daily, och fyra olika doseringar: 2,5 mg, 5 mg, 10 mg och 20 mg, erbjuder Cialis också en rad olika alternativ för att passa patientens behov.