2 ejemplos
 
el primero no funciona    
Código Javascript
:
Ver original- <html>  
-     <head>  
-         <script type='text/javascript'>  
-          
-         function asgg(){ 
-             <?php echo "mensaje"; ?>  
-                      } 
-         </script>  
-     </head>  
-     <body onload="asgg()">  
-       
-     </body>  
- </html> 
el otro si    
Código Javascript
:
Ver original- <html>  
-     <head>  
-         <script type='text/javascript'>  
-         <!--  
-             function alertar(){  
-                 alert(<?php echo "'hola'"; ?>);  
-             }  
-         //-->  
-         </script>  
-     </head>  
-     <body onload='alertar()'>  
-       
-     </body>  
- </html> 
no entiendo, como se puede ejecutar un php dentro de un javascript, sin haber cerrado el js antes, son lenguajes diferentes, se interpretan desde 2 lados distintos, servidor y cliente.
Porque uno anda y el otro no?