diff --git a/.gitignore b/.gitignore index 9141126..a82ca6b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ /vendor /node_modules + +/docs diff --git a/docs/CNAME b/docs/CNAME deleted file mode 100644 index 7f00477..0000000 --- a/docs/CNAME +++ /dev/null @@ -1 +0,0 @@ -phpapprentice.com \ No newline at end of file diff --git a/docs/arithmetic.html b/docs/arithmetic.html deleted file mode 100644 index cc01003..0000000 --- a/docs/arithmetic.html +++ /dev/null @@ -1,84 +0,0 @@ - - - -
- - -<?php
-
-
$a = 1;
-$b = 2;
-
-
$c = $a + $b;
-
-
$c = $b - $a;
-
-
echo $a * $b;
-
-
echo $b / $a;
-
-
$modulo = 10 % 5;
-
-
echo 5 ** 2;
-
<?php
-
-
$taskList = array('grocery store', 'change car oil');
-
-
$groceryList = ['bread', 'milk', 'eggs'];
-
-
echo $groceryList[0] . "\n";
-echo $groceryList[1] . "\n";
-
-
$car = ['make' => 'Toyota', 'model' => 'Camry'];
-
-
echo $car['model'] . "\n";
-
<?php
-
-
echo "Hello World!\n";
-
-
-
echo 'I am some text';
-
-
-
'I am a string';
-"\nI am a string on a new line";
-
-
echo "No semi-colon is a no-no\n";
-
-
echo 'Hello'; echo " World\n";
-
<?php
-
-
-
$a = true;
-$b = true;
-$c = false;
-
-
$a && $b;
-
$a && $c;
-
-
$a = true;
-$b = false;
-$c = false;
-$d = true;
-
-
$a || $b;
-
$b || $c;
-
$a || $d;
-
-
$d = true;
-
-
echo !$d;
-
<?php
-
-
class Car
-{
-}
-
-
$car = new Car();
-
-
class Bicycle
-{
- public $color;
-}
-
-
$bike = new Bicycle();
-$bike->color = 'Blue';
-echo $bike->color . "\n";
-
-
class Tricycle
-{
- public $color;
-
- public function echoColor()
- {
- echo $this->color . "\n";
- }
-}
-
-$bike = new Tricycle();
-$bike->color = 'Red';
-$bike->echoColor();
-
<?php
-
-
$a = true;
-$b = false;
-
-
$one = 1;
-$two = 2;
-
-
$one == $two;
-
-
$one != $two;
-
-
$one > $two;
-
-
$one < $two;
-
-
$one <= $two;
-$one >= $two;
-
-
-
1 == '1';
-
-
1 === '1';
-
<?php
-
-
$animal = 'cow';
-if ($animal == 'cow') {
- echo "Moooooo.....\n";
-}
-
-
-
-
$animal = 'bird';
-if ($animal == 'dog') {
- echo "Woof! πΆ\n";
-} elseif ($animal == 'cat') {
- echo "Meow!? π±\n";
-} elseif ($animal == 'bird') {
- echo "Chirp! π¦\n";
-} else {
- echo "I am not a dog, cat or bird\n";
-}
-
-
$food = 'apples';
-switch ($food) {
- case 'apples':
- echo "Eating an apple\n";
- break;
- case 'oranges':
- echo "Eating an orange\n";
- break;
- case 'peaches':
- echo "Eating a peach\n";
- break;
- default:
- echo "No food, I am hungry\n";
-}
-
-
$drink = 'water';
-switch ($drink) {
- case 'water':
- echo "Drinking water\n";
- case 'tea':
- echo "Drinking tea\n";
- break;
-}
-
-
$language = 'english';
-echo $language == 'spanish' ? "hola\n" : "hello\n";
-
-
echo $IDoNotExist ?? "Variable not set\n";
-
-
$IExist = "Variable exists\n";
-echo $IDoNotExist ?? $IExist ?? "Neither variable is set\n";
-
- PHP Apprentice was inspired by - Go By Example and by Elixir School. Both sites offer excellent, quality documentation in Go and Elixir and I want PHP Apprentice to provide the same - experience for the PHP programming language. -
-- Source Links: -
- PHP Apprentice was built using several open source projects. - Thank you to each of these maintainers for providing great libraries! -
- -<?php
-
-
-
function hello_world() {
- echo "hello world\n";
-}
-
-
hello_world();
-
-
function greet($firstname, $lastname) {
- echo "hello $firstname $lastname\n";
-}
-
-
greet('John', 'Smith');
-
-
function capitalize($value) {
- return strtoupper($value);
-}
-
-
$animal = capitalize('dog');
-echo "$animal\n";
-
-
$sum = function ($a, $b) {
- return $a + $b;
-};
-
-
echo $sum(1, 2) . "\n";
-
- The goal of PHP Apprentice is to be an easy to understand resource for learning how to write good code in the PHP programming language. There are a lot of PHP tutorials on the internet that use outdated libraries, insecure programming practices or inefficient code. I want this site to show how to write PHP code with quality. -
-- The site currently has content for learning the basics of PHP. In the future, more pages will be added for more advanced topics like building websites, database integration and security. -
-- PHP Apprentice is currently a work in progress (hence "beta" is included in the title). If you would like to contribute or request a certain discussion topic, checkout the GitHub repository. -
-- To get started, you will need to install PHP 7.1, have a text editor and open your terminal. - Each example in PHP Apprentice can by typed into a PHP file and executed in the terminal. - Let's get started! π -
- - - Open First Chapter - -<?php
-
-
$num = 5;
-while ($num > 0) {
- echo "While loop $num\n";
- --$num;
-}
-
-
$num = 0;
-do {
- echo "Do while $num\n";
- ++$num;
-} while ($num < 5);
-
-
for ($i = 0; $i < 10; $i++) {
- echo "For loop $i\n";
-}
-
-
$set = [1, 2, 3, 4, 5];
-foreach ($set as $num) {
- echo "Array value $num\n";
-}
-
-
$values = ['one', 'two', 'three'];
-foreach ($values as $value) {
- if ($value === 'two') {
- break;
- }
- echo "Break $value\n";
-}
-
-
$values = ['one', 'skip', 'three'];
-foreach ($values as $value) {
- if ($value === 'skip') {
- continue;
- }
- echo "Continue $value\n";
-}
-
<?php
-
-
$greeting;
-
-
$greeting = 'Hello World!';
-
-
echo $greeting;
-
-
$_var = 'I am a variable with an underscore!';
-$Var = 'I am a variable with a capital letter!';
-$var = 'I am a new variable';
-
-
$int = 1;
-$float = 100.10;
-$bool = true;
-$string = 'I am a string';
-
-
$number = 1;
-$number = 'one';
-