• PHP Video Tutorials

PHP - strval() Function


Advertisements

Definition and Usage

The function strval() gets string value of a variable.

Syntax

string strval ( mixed $value )

Parameters

Sr.No Parameter Description
1

value

The variable that is being converted to a string.

value may be any scalar type or an object that implements the __toString() method. You cannot use strval() on arrays or on objects that do not implement the __toString() method.

Return Values

This function returns string value of value. This function does not format the returned value.

Dependencies

PHP 4 and above

Example

Following example demonstrates use of function strval():

  <?php
  $a = "Tutorialspoint";
  var_dump(strval($a)) ;
  echo "<br>";
  $b = 40;
  var_dump(strval($b));
  echo "<br>";
  $c = NULL;
  var_dump(strval($c));
  echo "<br>";
  $d = array("a", "b", "c");
  var_dump(strval($d)); //This will print only the type of value being converted i.e. 'Array'
  echo "<br>";
  $e = '';
  var_dump(strval($e));
  echo "<br>";
  ?>

Output

This will produce following result −

  string(14) "Tutorialspoint"
  string(2) "40"
  string(0) ""
  string(5) "Array"
  string(0) ""

Useful Video Courses


Video

PHP Online Training

45 Lectures 9 hours

Malhar Lathkar

Video

Become PHP Facebook Developer: Password-Less Authentication

34 Lectures 4 hours

Syed Raza

Video

Ultimate PHP & MySQL Web Development Course & OOP Coding

84 Lectures 5.5 hours

Frahaan Hussain

Video

Learn PHP from Scratch

17 Lectures 1 hours

Nivedita Jain

Video

E Commerce Website Development In PHP With PDO

100 Lectures 34 hours

Azaz Patel

Video

PHP in Telugu

43 Lectures 5.5 hours

Vijay Kumar Parvatha Reddy

Advertisements