rainyday.dev/freecodcamp/build-a-doc-page/index.html

90 lines
4.0 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PHP Documentation</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<nav id="navbar"><header>PHP Documentation</header>
<div><a class="nav-link" href="#PHP_Introduction">PHP Introduction</a></div>
<div><a class="nav-link" href="#Basic_PHP_Syntax">Basic PHP Syntax</a></div>
<div><a class="nav-link" href="#PHP_Variables">PHP Variables</a></div>
<div><a class="nav-link" href="#PHP_Conditional_Statements">PHP Conditional Statements</a></div>
<div><a class="nav-link" href="#PHP_Loops">PHP Loops</a></div>
</nav>
<main id="main-doc">
<section id="PHP_Introduction" class="main-section">
<header>PHP Introduction</header>
<p>PHP is an acronym for PHP Hypertext Processor. PHP files can contain HTML, CSS, and Javascript, which are run on a web server and sent to the browser as HTML.</p>
<p>PHP files end in the <code>.php</code> file extension.
<p>What is PHP?</p>
<ul>
<li>PHP is an acronym for "PHP: Hypertext Preprocessor"</li>
<li>PHP is a widely-used, open source scripting language</li>
<li>PHP scripts are executed on the server</li>
<li>PHP is free to download and use</li>
</ul>
</section>
<section id="Basic_PHP_Syntax" class="main-section">
<header>Basic PHP Syntax</header>
<p>A PHP script can be placed anywhere in the document.</p>
<p>A PHP script starts with <code>&lt;?php</code> and ends with <code>?&gt;</code></p>
<p>A simple PHP script</p>
<code>&lt;?php
echo "Hello World!";
?&gt;</code>
</section>
<section id="PHP_Variables" class="main-section">
<header>PHP Variables</header>
<p>A variable starts with the <code>$</code> followed by the name of the variable</p>
<p>Example</p>
<code>$firtName = "Baxter";</code>
<p>Rules for PHP Variables:</p>
<ul>
<li>A variable starts with the $ sign, followed by the name of the variable</li>
<li>A variable name must start with a letter or the underscore character</li>
<li>A variable name cannot start with a number</li>
<li>A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )</li>
<li>Variable names are case-sensitive ($age and $AGE are two different variables)</li>
</section>
<section id="PHP_Conditional_Statements" class="main-section">
<header >PHP Conditional Statements</header>
<p>In PHP we have the following conditional statements.
<ul>
<li><code>if</code> statement - executes some code if one condition is true</li>
<li><code>if...else</code> statement - executes some code if a condition is true and another code if that condition is false</li>
<li><code>if...elseif...else</code> statement - executes different codes for more than two conditions</li>
<li><code>switch</code> statement - selects one of many blocks of code to be executed</li>
</section>
<section id="PHP_Loops" class="main-section">
<header >PHP Loops</header>
<p>In PHP we have the following loop types</p>
<ul>
<li><code>while</code> - loops through a block of code as long as the specified condition is true</li>
<li><code>do...while</code> - loops through a block of code once, and then repeats the loop as long as the specified condition is true</li>
<li><code>for</code> - loops through a block of code a specified number of times</li>
<li><code>foreach</code> - loops through a block of code for each element in an array</li>
</ul>
</section>
<section class="reference">
<header>Reference</header>
<ul>
<li>The content from this page is from the w3schools <a href="https://www.w3schools.com/PHP/default.asp">PHP Tutorial</a>
</i>
<ul>
</section>
</main>
</body>
<html>