<?php

$string = "test &#039;";
echo html_entity_decode($string, ENT_QUOTES);