Forum Moderators: coopster

Message Too Old, No Replies

Javascript header and source in PHP

         

phpguy54

7:22 pm on Jul 16, 2008 (gmt 0)

10+ Year Member



Hey guys,

How would i put the following header in a php file?

So far i have this:

header("Content-type: text/javascript");

But i don't know how i would do the rest of the tags as you see below:

<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas"
});
</script>

thanks

IanKelley

7:38 pm on Jul 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The example code you're showing is HTML, meaning that 'Content-type: text/javascript' is the wrong header to send.

Instead, do not send that header, display the HTML as normal within the PHP file:

<?
$somePHP = 'Stuff';
?>

<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas"
});
</script>

<?
$morePHP = 'Code';
?>