In this tutorial, you shall learn how to create an empty string in PHP using single or double quotes, with example programs.

PHP – Create an empty string

To create an empty string in PHP, use a pair of single or double quotes and do not mention anything between them.

In the following code snippet, we create an empty string using single quotes and assign to the variable $x.

$x = '';

In the following code snippet, we create an empty string using double quotes and assign to the variable $x.

$x = "";

Example

In the following example, we create an empty string, and print it.

PHP Program

<?php
  $x = "";
  echo "String value : " . $x;
?>

Output

PHP - Create an empty string
ADVERTISEMENT

Conclusion

In this PHP Tutorial, we learned how to create an empty string using single or double quotes, with the help of example programs.