my code-
<?php
session_start();
$_SESSION['errors']="failed";
?>
<head>
function myfunc()
{
alert(<?php echo $_SESSION['errors']; ?>);
}
</head>
<body onload="myfunc();">
but alert msg is not popping up.
my code-
but alert msg is not popping up. |
||||
|
Two errors in your code:
Try this:
You might want to put the Note: It is assumed that file extension for your code is php. |
|||||||||
|
PHP will just print out
|
|||
|
Additionally you should ensure that your php output doesn't contain anything breaking the javascript string:
Note that I also escape the forward slash to ensure that |
|||
|
As a matter of fact, it's impossible to insert PHP code snippet in javascript. Because it's nonsense JS engine don't understand PHP. So, to ask such a question, you must provide
|
||||
|