This file contains 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 | |
$id = 1; // just an example ... use appropriate id | |
$user = $this -> modx -> getObject('modUser', $id); | |
if (!$user -> hasSessionContext('web')) { | |
$user -> addSessionContext('web'); | |
} |
This file contains 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>Exercise 01: Show text in a browser</title> | |
</head> | |
<body> | |
<?php | |
// Create a PHP page, with the standard HTML <head>, <title> and <body> tags. | |
// This is not strictly necessary but is good practice and should the first |
This file contains 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>Exercise 02: Arithmetic Operators and Variables</title> | |
</head> | |
<body> | |
<?php | |
// Create the following variables: | |
// $x = 10; |
This file contains 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>Exercise 03: Assigning Variables and Using Operators</title> | |
</head> | |
<body> | |
<?php | |
// Write a script to reproduce the output below | |
// Value is now 8. |
This file contains 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>Exercise 04: Creating Arrays</title> | |
</head> | |
<body> | |
<?php | |
// Create array that holds all the provinces of Kenya and output them to the | |
// browser from top to bottom |
This file contains 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>Exercise 05: Manipulating Arrays</title> | |
</head> | |
<body> | |
<?php | |
// Create your array of 30 high temperatures then find the average high | |
// temp, the five warmest high temps and the five coolest high temps. Print |
This file contains 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>Exercise 06: Multi-Dimensional Arrays</title> | |
</head> | |
<body> | |
<?php | |
// Create a multi-dimensional array called $multiCity. Here's the content | |
// for your array: City, Country, Continent; Tokyo, Japan, Asia; Mexico |
This file contains 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>Exercise 07: Loops</title> | |
</head> | |
<body> | |
<?php | |
// Write 3 scripts that will print the letters of the alphabet to the browser using a; | |
// * For loop |
This file contains 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>Exercise 08: Simple function</title> | |
</head> | |
<body> | |
<?php | |
// Functions in PHP can help automate repetitive tasks and enable you to | |
// reuse code with a simple function call. For your first function, we'll |
This file contains 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>Exercise 09: Function with arguments</title> | |
</head> | |
<body> | |
<?php | |
// First, create a function to accept two arguments, perform a calculation | |
// using them, and then return a sentence with the result to the browser. |
OlderNewer