<?php $string = '&';$result = htmlentities($string, ENT_QUOTES, 'UTF-8'); var_dump($result);
Standard input is empty
string(9) "&amp;"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!