Solution
index.php
<?php
if (!isset($_GET['pg'])) { $_GET['pg'] = 'c'; }
include('header.php');
require('pages.php');
switch ($_GET['pg']) {
case 'c':
lang_c();
break;
case 'cpp':
lang_cpp();
break;
case 'java':
lang_java();
break;
case 'fortran':
lang_fortran();
break;
case 'prolog':
lang_prolog();
break;
default:
echo '<h2>404 Error</h2><p>The requested page was not available</p>';
}
include('footer.php');
?>
header.php
<?php
$title = '404 Error';
$nav = '';
/* page: home */
if (!isset($_GET['pg'])) { $title = 'Programming Languages'; }
/* page: C */
if (isset($_GET['pg']) && $_GET['pg']=='c') { $title = 'C Language'; }
$nav .= '<a href="?pg=c" class="'.(($_GET['pg']=='c')?'currentPage':'').'">C</a>';
/* page: C++ */
if (isset($_GET['pg']) && $_GET['pg']=='cpp') { $title = 'C++ Language'; }
$nav .= '<a href="?pg=cpp" class="'.(($_GET['pg']=='cpp')?'currentPage':'').'">C++</a>';
/* page: Java */
if (isset($_GET['pg']) && $_GET['pg']=='java') { $title = 'Java Language'; }
$nav .= '<a href="?pg=java" class="'.(($_GET['pg']=='java')?'currentPage':'').'">Java</a>';
/* page: Fortran */
if (isset($_GET['pg']) && $_GET['pg']=='fortran') { $title = 'Fortran Language'; }
$nav .= '<a href="?pg=fortran" class="'.(($_GET['pg']=='fortran')?'currentPage':'').'">Fortran</a>';
/* page: Prolog */
if (isset($_GET['pg']) && $_GET['pg']=='prolog') { $title = 'ProLog Language'; }
$nav .= '<a href="?pg=prolog" class="'.(($_GET['pg']=='prolog')?'currentPage':'').'">ProLog</a>';
echo <<<__HTML__
<!DOCTYPE html>
<html>
<head>
<title>{$title}</title>
<link rel="stylesheet" href="/style.css" type="text/css" media="all">
</head>
<body>
<header>
<h1>Programming Languages</h1>
<nav>{$nav}</nav>
</header>
<main>
__HTML__;
?>
footer.php
<?php
date_default_timezone_set('America/Chicago');
$date_string = date('Y-m-d H:i');
echo <<<__HTML__
</main>
<script type="text/javascript" src="/theme/prism.js"></script>
<footer>
©{$date_string} - General Websites Inc.
</footer>
</body>
</html>
__HTML__;
?>
pages.php
<?php
function lang_c() {
echo <<<__HTML__
<p><strong>C</strong> (pronounced like the letter c) is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie, and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems, device drivers, protocol stacks, though decreasingly for application software. C is commonly used on computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems.</p>
<p>A successor to the programming language B, C was originally developed at Bell Labs by Ritchie between 1972 and 1973 to construct utilities running on Unix. It was applied to re-implementing the kernel of the Unix operating system. During the 1980s, C gradually gained popularity. It has become one of the most widely used programming languages, with C compilers available for practically all modern computer architectures and operating systems. C has been standardized by ANSI since 1989 (ANSI C) and by the International Organization for Standardization (ISO).</p>
<p>C is an imperative procedural language, supporting structured programming, lexical variable scope and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support. Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant C program written with portability in mind can be compiled for a wide variety of computer platforms and operating systems with few changes to its source code.</p>
<p>Since 2000, C has consistently ranked among the top two languages in the TIOBE index, a measure of the popularity of programming languages.</p>
<h2>Example</h2>
<pre class="language-c line-numbers"><code class="language-c">
__HTML__;
echo htmlentities('#include <stdio.h>
int main(void)
{
printf("hello, world\n");
}');
echo <<<__HTML__
</code></pre>
__HTML__;
}
function lang_cpp() {
echo <<<__HTML__
<p><strong>C++</strong> (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language, and many vendors provide C++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Embarcadero, Oracle, and IBM, so it is available on many platforms.</p>
<p>C++ was designed with systems programming and embedded, resource-constrained software and large systems in mind, with performance, efficiency, and flexibility of use as its design highlights. C++ has also been found useful in many other contexts, with key strengths being software infrastructure and resource-constrained applications, including desktop applications, video games, servers (e.g. e-commerce, web search, or databases), and performance-critical applications (e.g. telephone switches or space probes).</p>
<p>C++ is standardized by the International Organization for Standardization (ISO), with the latest standard version ratified and published by ISO in December 2020 as ISO/IEC 14882:2020 (informally known as C++20). The C++ programming language was initially standardized in 1998 as ISO/IEC 14882:1998, which was then amended by the C++03, C++11, C++14, and C++17 standards. The current C++20 standard supersedes these with new features and an enlarged standard library. Before the initial standardization in 1998, C++ was developed by Stroustrup at Bell Labs since 1979 as an extension of the C language; he wanted an efficient and flexible language similar to C that also provided high-level features for program organization. Since 2012, C++ has been on a three-year release schedule with C++23 as the next planned standard.</p>
<h2>Example</h2>
<pre class="language-cpp line-numbers"><code class="language-cpp">
__HTML__;
echo htmlentities('#include <iostream>
int main()
{
std::cout << "Hello, world!\n";
}');
echo <<<__HTML__
</code></pre>
__HTML__;
}
function lang_java() {
echo <<<__HTML__
<p><strong>Java</strong> is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need to recompile. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture. The syntax of Java is similar to C and C++, but has fewer low-level facilities than either of them. The Java runtime provides dynamic capabilities (such as reflection and runtime code modification) that are typically not available in traditional compiled languages. As of 2019, Java was one of the most popular programming languages in use according to GitHub, particularly for client–server web applications, with a reported 9 million developers.</p>
<p>Java was originally developed by James Gosling at Sun Microsystems. It was released in May 1995 as a core component of Sun Microsystems' Java platform. The original and reference implementation Java compilers, virtual machines, and class libraries were originally released by Sun under proprietary licenses. As of May 2007, in compliance with the specifications of the Java Community Process, Sun had relicensed most of its Java technologies under the GPL-2.0-only license. Oracle offers its own HotSpot Java Virtual Machine, however the official reference implementation is the OpenJDK JVM which is free open-source software and used by most developers and is the default JVM for almost all Linux distributions.</p>
<p>As of September 2022, Java 19 is the latest version, while Java 17, 11 and 8 are the current long-term support (LTS) versions.</p>
<h2>Example</h2>
<pre><code class="line-numbers language-java">
__HTML__;
echo htmlentities('public class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Prints the string to the console.
}
}');
echo <<<__HTML__
</code></pre>
__HTML__;
}
function lang_fortran() {
echo <<<__HTML__
<p><strong>Fortran</strong> (/ˈfɔːrtræn/; formerly FORTRAN) is a general-purpose, compiled imperative programming language that is especially suited to numeric computation and scientific computing.</p>
<p>Fortran was originally developed by IBM in the 1950s for scientific and engineering applications, and subsequently came to dominate scientific computing. It has been in use for over six decades in computationally intensive areas such as numerical weather prediction, finite element analysis, computational fluid dynamics, geophysics, computational physics, crystallography and computational chemistry. It is a popular language for high-performance computing and is used for programs that benchmark and rank the world's fastest supercomputers.</p>
<p>The IBM Blue Gene/P supercomputer installation in 2007 at the Argonne Leadership Angela Yang Computing Facility located in the Argonne National Laboratory, in Lemont, Illinois, USA.</p>
<p>Fortran has had numerous versions, each of which has added extensions while largely retaining compatibility with preceding versions. Successive versions have added support for structured programming and processing of character-based data (FORTRAN 77), array programming, modular programming and generic programming (Fortran 90), High Performance Fortran (Fortran 95), object-oriented programming (Fortran 2003), concurrent programming (Fortran 2008), and native parallel computing capabilities (Coarray Fortran 2008/2018).</p>
<p>Fortran's design was the basis for many other programming languages. Among the better-known is BASIC, which is based on FORTRAN II with a number of syntax cleanups, notably better logical structures, and other changes to work more easily in an interactive environment.</p>
<p>Since August 2021 Fortran has ranked among the top 15 languages in the TIOBE index, a measure of the popularity of programming languages.</p>
<h2>Example</h2>
<pre class="line-numbers language-fortran"><code class="language-fortran">
__HTML__;
echo htmlentities('program helloworld
print *, "Hello, World!"
end program helloworld');
echo <<<__HTML__
</code></pre>
__HTML__;
}
function lang_prolog() {
echo <<<__HTML__
<p><strong>Prolog</strong> is a logic programming language associated with artificial intelligence and computational linguistics.</p>
<p>Prolog has its roots in first-order logic, a formal logic, and unlike many other programming languages, Prolog is intended primarily as a declarative programming language: the program logic is expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations.</p>
<p>The language was developed and implemented in Marseille, France, in 1972 by Alain Colmerauer with Philippe Roussel, based on Robert Kowalski's procedural interpretation of Horn clauses at University of Edinburgh.</p>
<p>Prolog was one of the first logic programming languages and remains the most popular such language today, with several free and commercial implementations available. The language has been used for theorem proving, expert systems, term rewriting, type systems, and automated planning, as well as its original intended field of use, natural language processing. Modern Prolog environments support the creation of graphical user interfaces, as well as administrative and networked applications.</p>
<p>Prolog is well-suited for specific tasks that benefit from rule-based logical queries such as searching databases, voice control systems, and filling templates.</p>
<h2>Example</h2>
<pre class="line-numbers language-prolog"><code class="language-prolog">
__HTML__;
echo htmlentities('?- write(\'Hello World!\'), nl.
Hello World!
true.');
echo <<<__HTML__
</code></pre>
__HTML__;
}
?>
Go To Live Site