Hyvor Developer
  Home   Download   Copy
Code
<?php
function validate($str) {
	return trim(htmlspecialchars($str));
}

// calling validate function
echo '<pre>';
echo validate('  <script>  ');
echo '</pre>';
Result