How can I insert javascript in php?
<p>I'm trying to insert javascript into a div.  All of this is within a php document.</p>

<p>I am trying to get a div to fade into view when it's child div is loaded.
Parent div had id of 'subemail'  (this is hidden)
Child div with id 'error' is shown then it should fade in the above div.</p>

<p>Following is the script I'm trying to load but get error unexpected T_STRING, expecting ',' or ';'.</p>

<pre><code>&lt;script type="text/javascript"&gt;
  $(function(){$('div#subemail').fadeIn('slow');});
&lt;/script&gt;
</code></pre>

<p>The PHP document:</p>

<p>

<pre><code>    if (empty($_POST['sub_name'])) {
        $errors[] = 'Please type in your name';
    } else {
        $sub_name = strip_tags($_POST['sub_name']);
    }

    if (filter_input(INPUT_POST, 'sub_email', FILTER_VALIDATE_EMAIL)) {
        $sub_email = $_POST['sub_email'];
    } else {
        $errors[] = 'Please type in a valid email'; 
    }

    if ($errors) {
        echo '&lt;div class="errors"&gt;';
                    echo '&lt;script type="text/javascript"&gt;';
                    echo '$(function(){$('div#subemail').fadeIn('slow');});';
                    echo '&lt;/script&gt;';


        foreach ($errors as $error) {
            echo '&lt;p class="error"&gt;- ' . $error . '&lt;/p&gt;';
        }
        echo '&lt;/div&gt;';

    }
</code></pre>
