PHP Code Inside Jquery

PHP code can easily be added inside Jquery.


$(document).ready(function(){
    $('.selector').click(function(){
        <?php // php code goes here ?>
    });
});

Non Working Case
If you are trying to bound some PHP code with the click event then this is impossible in the way you are trying and PHP code will be executed as soon as page load without waiting for a click event.

Working Case
generate final javascript or jquery code using PHP then this is okay.

Leave a Reply

Your email address will not be published. Required fields are marked *