title: How do I call Bootstrap Modal from PHP?
body: <p>Quick question. How do I call a Bootstrap Modal from PHP? I have a form and when some error happen I want to show an alert modal to the user. I've tried many solutions from other topics but neither has worked.</p>
  
  <p>Here's what I've tried last:</p>
  
  <pre><code>echo '&lt;script type="text/javascript"&gt;';
  echo '$(\'#alertDuplicate\').modal(\'show\')';
  echo '&lt;/script&gt;';
  </code></pre>
  
  <p>and here's the modal:</p>
  
  <pre><code>&lt;!-- Modal Alert Duplicate --&gt;
      &lt;div class="modal fade" id="alertDuplicate"&gt;
          &lt;div class="modal-dialog" role="document"&gt;
              &lt;div class="modal-content"&gt;
                  &lt;div class="modal-header"&gt;
                      &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;×&lt;/button&gt;
                      &lt;h4 class="modal-title"&gt;Erro&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;
                      &lt;p&gt;Essa função já existe!&lt;/p&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-footer"&gt;
                      &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Fechar&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;&lt;!-- /.modal-content --&gt;
          &lt;/div&gt;&lt;!-- /.modal-dialog --&gt;
      &lt;/div&gt;&lt;!-- /.modal --&gt;
  </code></pre>