I would like to wrap my Jquery/javascript in PHP out of security reason, I think PHP is much more difficult to access then client-side script. I Googled for this subject but there is really not much info, some examples which really don’t specify and that’s it. I really need just a starting idea in order to work on my actual script. So for example lets say I have this:
<script>
$("p").click(function () {
$(this).slideUp();
});
</script>
Would it suffice like this:
<?php
<script>
function click{
$("p").click(function () {
$(this).slideUp();
});
}
</script>
?>
echo click()
I’m asking for a basic understanding of this since I get nothing out of google. An anwser regarding my code would be appreciated.
You can’t hide jQuery code from the user. It will always be part of the HTML page that is sent to the user’s browser and he can always open the source code view and have a look at it. It has to be this way, because jQuery is JavaScript and that is executed by the browser, not the server. If you don’t tell the browser what to do, it can’t do it. Simple as that.
Obviously you can use PHP to generate jQuery code, but in the end it will be transmitted to the user’s browser just the same.