PHP Strings

PHP Strings

String Operations:

Concatenation Operator:  .

String variables individual characters can be accessed through { }

Index of characters in string starts with zero

String Functions:

strlen()

strcmp()

strpos()

substr()

chop()

trim()

ltrim()

strtolower()

strtoupper()

 

 

Type Conversion:

In PHP Explicit type conversion can be performed in three different ways:

  • Type Casting for example $sum = 10.78; (int)$sum will be 10
  • Type conversion functions: intval, doubleval, strval ex: intval($sum)
  • settype function: takes two parameters: variable and string specifying type name. Ex: settype($sum,”integer”);