forms - how to convert altcodes to html code in php -


i'm working on website have form, if enter text works should if enter special characters ☺ ☻ ♥ ♦ becomes lot of ?? in database. there way convert them html code?

example: convention served ♥

the function looking htmlentities http://php.net/manual/en/function.htmlentities.php

you'll need know encoding input data uses (obviously). default utf8.

$encoded = htmlentities( $input, ent_compat | ent_html401, 'utf-8', false ); 

note i've set final parameter false (default true). users can type, example, & , convert &. maybe want default behaviour (& -> &)

the encoding used when sending post data can set in form tag:

<form method="post" action="myscript.php" accept-charset="utf-8"> 

but see here discussion: is there benefit adding accept-charset="utf-8" html forms, if page in utf-8?


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -