PHP

From pronounmail wiki
Revision as of 18:30, 4 September 2024 by Leah (talk | contribs) (Created page with "'''PHP''' stands for '''Ph'''antastic '''P'''rogramming. You can use it to make things happen on pages. It's different from JavaScript because JavaScript runs in your browser and PHP runs somewhere else I don't know where.They won't tell me where it runs. == Having a PHP == You can make a php script by calling it <code>something.php</code>. It's a good idea to actually call it <code>something/index.php</code> so the URL remains the same if you decide to stop using PHP...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

PHP stands for Phantastic Programming. You can use it to make things happen on pages.

It's different from JavaScript because JavaScript runs in your browser and PHP runs somewhere else I don't know where.They won't tell me where it runs.

Having a PHP

You can make a php script by calling it something.php. It's a good idea to actually call it something/index.php so the URL remains the same if you decide to stop using PHP (a wise choice).

Writing a PHP

You can write a PHP script like this:

<?php
echo "this is my cool script";

There's a pretty okay guide on the PHP website.

The <?php bit tells PHP you're about to write some PHP. You can stop writing PHP and start writing HTML with ?>.

Sometimes you'll want to insert some values from PHPland into your HTML, which you can do like this:

<?php
$my_value = "hello!";
?>

<p>
  <?= $my_value ?>
</p>

Note that if you're rendering user input in this way, you should wrap it in the strip_tags function, lest you become vulnerable to an XSS (Cross-site scripting) attack in which a nasty fellow inputs evil HTML to make your site go bad and rotten like a hard-boiled egg.