Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>PHP runs on the <code>server</code>.</p> <p>Javascript runs within the <code>browser</code> (what's called the <code>client</code>).</p> <p>They are completely distinct. You can do a website without Javascript; however, any in-browser "scripts" will not run with PHP being given to the browser, since the browser does not understand PHP.</p> <p>So think about it like this...</p> <ol> <li>You create a PHP page on your server, called mypage.php. </li> <li>Within it contains PHP code.</li> <li>The PHP code is parsed on the server when accessed over HTTP (http://example.com/mypage.php).</li> <li>Which sends the output, or HTML and other "resources" (Javascript and CSS mostly), to the browser (client).</li> </ol> <p>Javascript would be part of the response to the browser requesting the mypage.php content. On the server, HTML/Javascript/CSS are considered a special kind of text, and have no bearing on the PHP code itself. PHP is meant to ease the management of outputting HTML/Javascript/CSS to browsers, mostly.</p> <p><strong>A More Extensive Answer</strong></p> <p><em>Server - mypage.php</em></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; body p { background-color: #dddddd; color: #ff0000; } &lt;/style&gt; &lt;script type="text/javascript"&gt; alert('Thank you for visiting!'); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;&lt;?php print 'Hello World!'; ?&gt;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><em>What the browser (client) sees</em> - <a href="http://example.com/mypage.php" rel="nofollow">http://example.com/mypage.php</a></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; body p { background-color: #dddddd; color: #ff0000; } &lt;/style&gt; &lt;script type="text/javascript"&gt; alert('Thank you for visiting!'); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Hello World!&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Notice the script tags stay as they are, but the PHP tags go away. They are <code>parsed</code> by the PHP parser on the server-side, before outputting the HTML code (with style and script tags intact) to the browser (client).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload