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
.
</>
Copy
$x = '';
In the following code snippet, we create an empty string using double quotes and assign to the variable $x
.
</>
Copy
$x = "";
Example
In the following example, we create an empty string, and print it.
PHP Program
</>
Copy
<?php
$x = "";
echo "String value : " . $x;
?>
Output
Conclusion
In this PHP Tutorial, we learned how to create an empty string using single or double quotes, with the help of example programs.