top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Can I include Javascript in my PHP code?

+1 vote
513 views
Can I include Javascript in my PHP code?
posted Jun 26, 2014 by Karamjeet Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Yes ,You can include javascript in PHP Code.Using echo or print you can include any HTML tags like style,script etc.

For Example:

print("<script type=\"text/javascript\"> alert('This is an example for Javascript inside Php Code'); </script>");
echo("<script type=\"text/javascript\" src=\"Calculation.js\"></script>");
answer Jun 26, 2014 by Parampreet Kaur
+1 vote

Yes,you include javascript into your PHP code. Here is an example.




<?php if(isset($_POST['btn'])){ echo " <script type=\"text/javascript\"> var e = document.getElementById('testForm'); e.action='test.php'; e.submit(); "; } ?>
answer Jun 27, 2014 by Mohit Sharma
Similar Questions
+2 votes

Is there any way so that i will get to know about my variable is a number or not without using Javascript?

0 votes

As per my understanding of interpreted language is scripting(interpreted) language is the language which can executed by CPU straight away without any need of compilation are classified as scripting language

Now if i take example of JavaScript , it does not requires explicit compilation from developer. But browser which interprets actually converts it in to machine instruction which CPU can execute.

So in a way it is also a compiled language though compilation is not required by developer explicitly but browser does it internally. Is n't it ?

Same is the case with PHP.

0 votes

For example say I want include("abc.php") two times in a PHP page?

...