phpファイル内でjqueryの記述をする方法

<script>
$(function(){
$(".ac").on("click", function() {
$(this).next().slideToggle();
if ($(this).children(".accordion_icon").hasClass('active')) {
$(this).children(".accordion_icon").removeClass('active');
}
else {
$(this).children(".accordion_icon").addClass('active');
}
});
});
</script>