MOUSELING.net

Tutorials

For tutorials and similar things. Will hopefully expand with time. Reverse chronological order!

Using PHP includes for a consistent site layout

2026-10-08

I consider HTML a gift from God, and I love PHP—it's a very powerful aid, and you don't have to do any crazy programming with it. I even find it better not to bother with all of that, if I want to keep "the spirit" of my websites close. The one reason I seeked to use PHP at all was to keep my layouts consistent without having to copy-paste everything, and in the case of changes, and you can do this too!

If you use the same layout on many of your pages and aren't limited by a static host (e.g. Neocities or Nekoweb), and can ensure PHP is on your Web server, then I highly recommend trying it out. One line of copy-pasted code could save your life...

Setting things up

First, ensure you have PHP. That's not a part of this tutorial, so if that's not you, get up and pray.

I would recommend making a folder in your site files called something like /php/, /inc/, /layout/, et cetera... then, inside that, you'll want two files: header.php and footer.php. These can be called whatever you want, though. Top & bottom, start & end, dog & cat... the important part is that they exist, you know where they live, and you can call upon them.

Finally, make sure that all of the pages that you want to use your layout on, you'll want to make them end with .php instead of .html. Update your links accordingly!

Putting your layout in the PHP files

Let's say you have a basic page with the following code:

<html>
<head>
  title>My Website</title>
  <link rel="stylesheet" href="/css/style.css">
</head>

<body>

<header>
  <img src="/img/layout/banner.png">
  <h1>My Website Title</h1>
</header>

<nav>
  <h2>Links</h2>
    <a href="page.php">Page 1</a>
    <a href="page2.php">Page 2</a>
</nav>

<main>
  <h2>Cool Page</h2>
    <p>This is my page for cool things.</p>
</main>

<footer>
  This website belongs to me.
</footer>

</body>
</html>

Your first job is to split this up according to what you use repeatedly and what you change for each page. Let's say that each page only differs by its title and content. Your header.php would become:

<html>
<head>
  title>My Website</title>
  <link rel="stylesheet" href="/css/style.css">
</head>

<body>

<header>
  <img src="/img/layout/banner.png">
  <h1>My Website Title</h1>
</header>

<nav>
  <h2>Links</h2>
    <a href="page.php">Page 1</a>
    <a href="page2.php">Page 2</a>
</nav>

<main>

And your footer.php might become:

</main>

<footer>
  This website belongs to me.
</footer>

</body>
</html>

Using the layout files

With all of this taken out, it looks like there's nothing on the page itself. What happens to the page now?! With nothing surrounding it, the page looks light as a feather... but there's the fun part.

To include a file with PHP is to grab all of its contents, dump it into the current file, and then work with that information. Here, we will use this function taking the layout content we cut away and throwing it back into the file before showing it to the user.

The code we will be using is written like this:

<?php include $_SERVER['DOCUMENT_ROOT'] . '/layout/header.php' ; ?>

I've colour-coded the parts to make it a little easier to read, because it seems a bit daunting at first. You only need to change the red part when you include something. It's quite a strong functionality. To explain what each part does:

<?php ...; ?>
PHP is a language designed from the ground up to be used alongside HTML, and HTML uses <these brackets> to define its tags. But how can a computer tell PHP code from regular HTML? By using these question marks along with the letters php, the computer can tell that this is a PHP tag and act accordingly. Also, PHP code ends with semilicons. Because it's nicer that way.
include
This tells the server to include something.
$_SERVER['DOCUMENT_ROOT'] .
This ensures that the server looks for the file starting at the server's root. Without this, a file like /subfolder/file.php would end up looking for /subfolder/layout/header.php by mistake.
'/layout/header.php'
This is the file you are including. You may change whatever is inside the quotes to whatever is applicable.

Armed with this knowledge, we can finally change our page's code. The entire source becomes this:

<?php include $_SERVER['DOCUMENT_ROOT'] . '/inc/header.php'; ?>

<h2>Cool Page</h2>
  <p>This is my page for cool things.</p>

<?php include $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.php'; ?>

From now on, your only worry is whatever's inside the main part of each Web page. As long as your other pages are set up this way too, you can abuse this infinitely.

You're all set up with a PHP-powered layout now. Change one thing about your layout's HTML and everything else will follow suit just dandy!.

Read More...

Portable applications are more useful than you think

2026-02-11

If you move around computers a lot, whether it be for school or work or personal reasons, you probably have a USB with some spare storage to keep various important files on. This assumes, of course, that every computer you interact with has the programs you need to use. Often they will; sometimes they won't.

When it comes to persistent projects using the same application on various different PCs, some people will find Puppy Linux—a type of Linux distribution contained entirely on a USB, designed with portability in mind—the way to go. But what if you are used to working in a Windows environment, or the computers you work with don't allow you to mess with their boot order?

This is how I discovered the value in portable installations.

Read More...

Pure CSS to distinguish out-links from in-links

2025-08-09

Here's a fun problem I came across some time ago, while designing my site cattle mutilation: I wanted to distinguish out-links from in-links visually... without manually adding a new class to all my out-links... without any nasty JavaScript involved. There was always the option of just using JS, linking a little script in the header of all my pages and calling it a day, but I was steadfast on the aesthetics being immediate and without such bloat.

So, intent on doing everything I could to make this happen, I took to Google. I asked it: How do you make an outlink styled differently? That didn't lead to much that was relevant. Eventually, I discovered something wonderful which I didn't know I was already using: CSS pseudo-classes. Furthermore, I discovered a new type of selector to go with class and ID selectors, the humble attribute selector.

Read More...

The Angura Kei Poser Guide

2025-05-30

Angura Kei is a term that gets thrown around a lot. Some people claim it's a very real thing, some people claim it's an entirely made up thing, and nobody can decide whether it's separate from eroguro-kei or not. As an Angura Kei expert[citation needed] (delusional fanatic) I think I am qualified not only to settle the matter but to teach all of my adoring fans how to truly become Angura Kei.

To become Angura Kei, you need to dress the part like all good fans do. In fact, dressing the part is perhaps the most important part of the whole affair. You can throw the bands out entirely as long as you claim to listen to SEX-ANDROID. Of course, Angura Kei bands dress all sorts of ways, but to be Angura you should do shironuri (paint yourself white). How will we know you come from that angura (mutilation of "underground") Kabuki-theatre Visual Kei scene?

Please ignore the several bandmen who show up on stage with their own skin tone and the Angura bandmen with little or even no makeup. You will do your white make and you will be happy.


Tip: if you're new to being a poser, try listening to the band you'll pretend to be into exactly once so that you can claim to have a favourite song.

So, let's give you a shironuri tutorial, photos and all. I'll teach you how to turn yourself from a barefaced wreck into a true bandman doppelganger, because you probably saw a Muchi Muchi Anago cosplayer on Pinterest labeled "Gloomy bear girl" and used that photo for your pinned Tweet while not knowing shit about Hachiyama Yuumi.

My shironuri process is very simple and very quick. I can get my makeup done in less than ten minutes and I barely need a mirror. That is because my makeup is generally awful, but why wouldn't it be?

Read More...