Infoboxes are being rewritten. You might see images or tabs broken or behaving weirdly during the move. Infoboxes use galleries instead of tabbers now. See the source of Broot for more info.
PHP
You can read this for more info about the topic |
|---|

PHP is a general-purpose scripting language especially suited to web development. Its syntax is similar to Java and Perl and was originally created by Canadian programmer Rasmus Lerdorf in 1993 as a set of Common Gateway Interface (CGI) binaries written in C for tracking visits to his online resume. Over time, PHP evolved into a powerful server-side scripting language that now powers millions of websites, such as soyjak.party and even this very wiki. Even though it is sometimes seen as “old” or “messy” compared to newer frameworks and languages, PHP still sees heavy use so don’t believe what the angry Chud programmers on Twitter or Reddit say. In fact, PHP still gets plenty of feature updates making it still just as good with other competitive server-side languages. Its ease of deployment, gigantic ecosystem of frameworks and libraries, and the sheer number of legacy PHP sites still online ensure that PHP will be around for a long time to come.
Notable features[edit | edit source]

PHP is best known for:
- PHP code runs on the server and generates HTML to be sent to the client’s browser. This makes it ideal for building websites, content management systems, and web applications.
- PHP has an massive library of frameworks, plugins, and tools thanks to it's wide adoption and ecosystem from platforms such as ACK!press.
- PHP can be mixed directly with HTML code, making it beginner-friendly and great for creating templates.
- PHP works seamlessly with SQL systems, such as MySQL, PostgreSQL, SQLite, and other databases to create dynamic, data-driven websites.
- PHP runs on Windows, Linux, macOS, and most web servers, making it highly versatile.
- By using the
declare(strict_types=1)directive, PHP can enforce strict types and type information.
How does PHP work?[edit | edit source]
At the heart of PHP is the Zend Engine, a open-source compiler and runtime environment for the PHP scripting language. Whenever a PHP file is requested, the following happens behind the scenes:
- The PHP interpreter lexes the PHP code, then converts it into an internal representation called an abstract syntax tree.
- The Zend Engine then compiles the syntax tree into low-level opcodes, which are a simplified set of instructions optimized for execution.
- The Zend Engine executes the opcodes line by line, handling function calls, database queries, file I/O, and any other server-side logic.
- The result of the script (usually HTML, XML or another format) is sent back to the web server, which delivers it to the client’s browser.
Scripts[edit | edit source]
CSS switcher[edit | edit source]
css.php
include this in the <head> of your php script.
<?php
if (!isset($_COOKIE['theme'])) {
setcookie("theme", "yotsuba", time() + (86400 * 399), "/");
} else {
$theme = $_COOKIE['theme'];
}
if ($theme == "light") {
echo("<link href='/soychiver/base.css' rel='stylesheet'>");
} else if ($theme == "dark") {
echo("<link href='/soychiver/base.css' rel='stylesheet'>");
echo("<link href='/soychiver/dark.css' rel='stylesheet'>");
}
theme.php
This is where the user chooses their theme.
<?php
function setTheme($theme) {
setcookie("theme", $theme, time() + (86400 * 399), "/");
header("Location: index.php");
exit;
}
$themearray = ['light', 'dark'];
if (isset($_GET['a']) && in_array($_GET['a'], $themearray)) {
setTheme($_GET['a']);
} else {
die("Available themes: <a href='?a=light'>Light</a> <a href='?a=dark'>Dark</a>");
}
Textboard[edit | edit source]
This is a simple way of how an imageboard works.
- You go to the server, and fetch "index.html".
- You enter your shit thread / reppey in the post form, and send it off; usually to
imgboard.php - The server submits your thread into the database and regenerates index.html with the new thread in it
The reason that the post index doesn't generate on the fly (e.g. with index.php) is because:
- That would use more processing power than needed
- It's an anonymous imageboard, there are no user-specific algorithms.
The code itself[edit | edit source]
This is a textboard because I can't be asked to make an imageboard in php. You can change it all you like, freely, if you want. It's based of Gazou BBS (Yotsuba, OpenYotsuba and Vichan both originated from this script if that matters)
<?php
// DO NOT USE THIS IN PRODUCTION, currently you can't post but nophono cares
// These are constants: variables that don't change
define("PHP_SELF", "imgboard.php"); // This file
define("PHP_SELF2", "index.html"); // The index file
$log = "imglog.log"; // The post log file
$title = "North Textboard"; // Your board title
// The log should look like:
// 1|01-01-2025|Subject|Name|Body
// 2|02-01-2025|Another post|North|sdfasdfasgdfafgs
$poststring = file_get_contents($log); // Gets contents of the log
$postlist1 = explode("\n", $poststring); // Creates a 1 dimensional array of all cells in the log
// No more comments here on out! It should be obvious doe.
$dat="<html><head><title>$title</title></head>
<body bgcolor=#ffffee text=#800>
<p align=right>
[<a href='".PHP_SELF."'>Rebuild Index</a>]
</p>
<p align=center>
<font color=#800000 face='MS PGothic' size=5>
<b><SPAN>$title</SPAN></b><br></font></p><hr>";
foreach ($postlist1 as $post2) {
$post = explode("|", $post2);
$dat.='<small>No.'.$post[0].'</small> <big><font color=#FF0000>'.$post[2].'</font></big><br>
<small>Name <font color=#117743>'.$post[3].'</font> Date '.$post[1].'</small><blockquote>';
$dat.=$post[4].'</blockquote></td></tr></table><hr>';
}
$dat.='<p align=center><small>Based off <a href="http://php.loglog.jp/">GazouBBS</a>, made by <a href="https://soyjakwiki.org/User:North"</a>North</a></small></body></html>';
file_put_contents(PHP_SELF2, $dat); // Puts $dat into the index file
header('Content-Type: text/plain'); // Nophono
header("Location: " . PHP_SELF2); // Redirects user 2 index
echo("Regenerating index..."); // Nophono
?>

