mirror of
https://github.com/restoreddev/phpapprentice.git
synced 2025-10-23 02:46:04 +02:00
79 lines
4.0 KiB
HTML
79 lines
4.0 KiB
HTML
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
|
|
<title>Basics</title>
|
|
<meta name="description" content="Let us get started with the basics.">
|
|
|
|
<link rel="stylesheet" href="/css/site.css">
|
|
<link rel="icon" href="/favicon-32.png">
|
|
<script src="/js/site.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="menu">
|
|
<button class="menu-button" title="Open Menu">
|
|
<div class="icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z"/></svg></div>
|
|
Menu
|
|
</button>
|
|
</div>
|
|
|
|
<div class="container center">
|
|
<h1>Basics</h1>
|
|
<h3 class="subtitle">Getting started</h3>
|
|
<div class="grid-code"><div class="doc"></div><div class="code"><pre><code class="language-php"><?php
|
|
|
|
</code></pre></div><div class="doc">In the tradition of our ancestors, let's start with a hello world program. All PHP files must start with a <?php tag unless it is for a html template. (We will learn about html templates later.)</div><div class="code"><pre><code class="language-php">echo "Hello World!\n";
|
|
|
|
</code></pre></div><div class="doc">There is a lot going on in this statement so let's work through it.</div><div class="code"><pre><code class="language-php">
|
|
</code></pre></div><div class="doc">First, the echo keyword tells PHP to output some text.</div><div class="code"><pre><code class="language-php">echo 'I am some text';
|
|
|
|
</code></pre></div><div class="doc">Second, PHP stores text in strings.</div><div class="code"><pre><code class="language-php">
|
|
</code></pre></div><div class="doc">To write a string, you surround letters with single or double quotes. The difference between single quoted strings and double quoted strings is that double quoted strings can hold special characters like \n which tells PHP to start a new line.</div><div class="code"><pre><code class="language-php">'I am a string';
|
|
"\nI am a string on a new line";
|
|
|
|
</code></pre></div><div class="doc">Third, all lines of code in PHP must end in a semi-colon.</div><div class="code"><pre><code class="language-php">echo "No semi-colon is a no-no\n";
|
|
|
|
</code></pre></div><div class="doc">Using semi-colons means we can write multiple statements on one line.</div><div class="code"><pre><code class="language-php">echo 'Hello'; echo " World\n";
|
|
</code></pre></div></div>
|
|
<div class="clearfix"></div>
|
|
<div class="navigate-links">
|
|
<a href="/variables.html" title="Next">
|
|
Next
|
|
<div class="icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M10 0a10 10 0 1 1 0 20 10 10 0 0 1 0-20zM2 10a8 8 0 1 0 16 0 8 8 0 0 0-16 0zm10.54.7L9 14.25l-1.41-1.41L10.4 10 7.6 7.17 9 5.76 13.24 10l-.7.7z"/></svg></div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal closed">
|
|
<div class="modal-content">
|
|
<button class="modal-button right" title="Close">
|
|
<div class="icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm1.41-1.41A8 8 0 1 0 15.66 4.34 8 8 0 0 0 4.34 15.66zm9.9-8.49L11.41 10l2.83 2.83-1.41 1.41L10 11.41l-2.83 2.83-1.41-1.41L8.59 10 5.76 7.17l1.41-1.41L10 8.59l2.83-2.83 1.41 1.41z"/></svg></div>
|
|
</button>
|
|
<div class="table-of-contents">
|
|
<h4>Table of Contents</h4>
|
|
<a href="/index.html">Preface</a>
|
|
<ol>
|
|
<li><a href="/basics.html">Basics</a></li>
|
|
<li><a href="/variables.html">Variables</a></li>
|
|
<li><a href="/arithmetic.html">Arithmetic</a></li>
|
|
<li><a href="/comparisons.html">Comparisons</a></li>
|
|
<li><a href="/boolean-logic.html">Boolean Logic</a></li>
|
|
<li><a href="/conditionals.html">Conditionals</a></li>
|
|
<li><a href="/loops.html">Loops</a></li>
|
|
<li><a href="/arrays.html">Arrays</a></li>
|
|
<li><a href="/functions.html">Functions</a></li>
|
|
<li><a href="/classes.html">Classes</a></li>
|
|
</ol>
|
|
<a href="/credits.html">Credits</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|