Q:

include php function to javascript

in test.php file
<html>
<head>
  <script type="text/javascript" src="java_script.js"></script>
</head>
<body>

Name: <input type="text" id="myText" value="Mickey">

<button onclick="myFunction()">Click Me</button>

</body>
</html>

in java_script.js
function myFunction() {
    var user_name = 'Hellow World';
    document.getElementById("myText").value = user_name;
}

How to use function or variable from php_test.php
in php_test.php
  <?php
      $phpVar = 'Hello World';
      echo $phpVar;
  ?>

Thank you everyone 
i'm not good in English, You can correct me :)

A:

clabe45's answer is good, but I thought I'd add some more information in my own words.
PHP is a server-side language. It's run by the server. It can be used for whatever you want, but it's often used to generate HTML and sometimes Javascript. The HTML and Javascript is then sent to the browser. The browser parses (reads) the HTML and displays it in the browser, and it runs the Javascript. The HTML is what you see on the page (text, images, borders, etc.). The Javascript is used to add interactivity to the page (drop-down menus, animations, popup boxes, etc.).
Since PHP runs on the server and Javascript runs in the browser (on the client), Javascript can't access variables that are in the PHP code. The Javascript doesn't know anything about the PHP, and vice versa.
The way Javascript normally talks to PHP is through AJAX. The Javascript code can send an AJAX request to the server, and the PHP code on the server can respond to that request. clabe45's answer has some more details about AJAX (and you should definitely check out jQuery's AJAX functions, and google some tutorials).

