Another scenario where you can use both set_value and the default value:
The set_value()
function simply sets the value. This function is more useful for saving input values ββwhen submitting a form with validation errors. So the user does not need to re-enter the fields. This function has a second optional parameter, which allows you to set the default value for the form.
But if you want to fill in your default value if you use the same form to edit and add data.
<input type="text" name= "name" value = "<?php if($form['name']) echo $form['name']; else echo set_value('name');
The above statement sets the value if you add values ββto the form. If you edit the form, it simply displays the captured value from the database or published data.
source share