This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Example</title> | |
</head> | |
<body> | |
<h1>Example</h1> | |
<form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$array = ['red', 'green', 'blue']; | |
$quantity = count($array); | |
if ($quantity) | |
//if ($quantity = count($array)) | |
{ | |
echo "There are $quantity items"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$array = ['red', 'green', 'blue']; | |
$quantity = count($array); | |
// if ($quantity == 5) | |
//if ($quantity = 5) | |
if (5 == $quantity) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code to accompany this video: https://youtu.be/sOmHCk-_UaM | |
// 1. The concatenation operator | |
$message = "Hello " . "world"; // $message contains "Hello world" | |
// 2. The concatenating assignment operator | |
$title = "Home"; | |
$title .= " | About"; // $title now contains "Home | About" | |
// 3. Splitting concatenations onto more than one line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Code to accompany this video: https://youtu.be/faoGMg-n07Y | |
// 1. No checking for the variable being set | |
$page = $_GET['page']; | |
// 2. Using isset to check that the variable is set | |
if (isset($_GET['page'])) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Validation example</title> | |
</head> | |
<body> | |
<h1>Subscribe to our newsletter</h1> | |
<form method="post" action="process_form.php"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Code to accompany this video: https://youtu.be/tORiyyMds1M | |
// if ($_POST) { | |
// if (isset($_POST['sendButton'])) { | |
if($_SERVER['REQUEST_METHOD'] == 'POST') { | |
exit("form submitted"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($_FILES['file']['error'] !== UPLOAD_ERR_OK) { | |
throw new Exception('an error occurred'); | |
} | |
if ($_FILES['file']['size'] > 1000000) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
class Article | |
{ | |
private $title; | |
public function __construct($title) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
if ( ! file_exists("input.txt")) | |
exit; | |
*/ | |
/* | |
if ( ! file_exists("input.txt")) | |
echo "File not found\n"; |
OlderNewer