Welcome Guest, Not a member yet? Register   Sign In
How do I use esc() in html form input AND get readable text?
#1

(This post was last modified: 03-25-2024, 06:49 PM by objecttothis. Edit Reason: clarity )

Problem:
This code
PHP Code:
<?php $sample_text 'The quick brown fox!';
<?= 
form_input ([
 
'name' => 'sample_text',
 
'id' => 'sample_text',
 
'class' => 'form-control input-sm',
 
'value' => esc($sample_text'attr')
]) 
?>

Yields a textbox with the value "The&#x20;quick&#x20;brown&#x20;fox&#x21;"

How can I escape output but still produce readable text in the form? I want "The quick brown fox!" and simple sentences to be plaintext but everything else to be escaped.
Is 'attr' the correct context to use here?
Reply


Messages In This Thread
How do I use esc() in html form input AND get readable text? - by objecttothis - 03-25-2024, 06:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB