Possible Duplicate:
Pass a PHP string to a Javascript variable (and escape newlines)
I am quite new to the concepts of Javascript/jQuery and PHP. I have been using PHP implemented in Appserv for two weeks now to get data from a modbus device and store it in a csv file. Now i want to plot the data using jQplot. I am trying to write a simple program to first see if i can implement php and javascript code together in html. This is a code that i have written in html and uses both javascript and php.
<!doctype html>
<html>
<head>
<title>Demo</title>
</head>
<body>
<h2>This is a script</h2>
<script type="text/javascript">
var out = <?php echo "Hello"?>;
//var out = "Hello"
document.write(out);
</script>
</body>
</html>
When i run this code in the browser ( I use google chrome with windows 7) I only get the heading "This is a script". However if i remove the line with the php code and uncomment the next line
var out = "Hello";
then the code prints the output with "Hello" like its supposed to. Why is this?