Destroying Variable in PHP

In this tutorial, we are going to see how the unset() function works in PHP. Let's check it out!

Well, it destroys a variable in your coding. After destroying a variable, you can re-create that variable for different purpose or value. It's very straight-forward. For better understanding, please take a look to the codes below:

<?php
//destroying variable
$car = "Nissan";
echo "<p>The current car is $car. ";
unset($car);
$car = "Toyota";
echo "After destroying car, the new car is $car.</p>";
?>

Simply copy and paste those codes above, and you will see how it works. Happy Coding...!

Labels: , , ,