We Engineering Revision Notes
We Engineering Revision Notes
We Engineering Revision Notes
require 'file.php';
require 'file.php'; //Allowed
require_once 'file.php';
require_once 'file.php'; //Only included once
print_r([1, 2, 3]);
SOAP Based:
- Healthcare Information Systems
- Banking Applications
- Finance Applications
Government Applications
REST Based:
- Content Management Systems
- Weather Forecasting Systems
- Blogging Websites
- Flight Booking Websites
<body>
<h1>My Survey</h1>
<div>
<label for="age">Age:</label>
<input type="number" id="age" name="age" max="99">
</div>
<button type="submit">Submit Responses</button>
</form>
</body>
</html>
Added more semantics with language attribute, descriptive IDs/names, labels etc.
if(name.value.length === 0) {
alert("Please enter your name");
return false;
}
$stmt = $dbConnection->prepare($insertSql);
$result = $stmt->execute();
if(!$result) {
throw new Exception("Error inserting survey response");
}
(php)
// Create new app skeleton
Laravel new MyApp
// Make controller
Php artisan make:controller FormController
// Basic route
Route::get(‘/form’, ‘FormController@show’);
// Render view
Return view(‘form’);
Laravel utilizes many other powerful features like Eloquent ORM database interfacing,
authentication, queues and caches to construct robust applications.
Xhr.onload = function() {
// Handle response
updatePage(xhr.response);
}
Xhr.send();
Function updatePage(data) {
// Render into DOM
}
Benefits include improved perceived performance and flexibility. Tradeoffs include more client-side
work and considerations around JavaScript support.
Developers often construct database queries by combining hard-coded SQL with unfiltered user
inputs. This allows attackers to manipulate the execution by injecting malicious code. For example:
If $input contains crafted strings like ‘; DROP TABLE users;’, it would alter query execution arbitrarily.
$stmt->execute([$input]);
Binding variables eliminates injection risks. Input validation is still required to filter unexpected
values.
Cryptographic hashes generate fixed length fingerprints of arbitrary data like passwords. Early
algorithms such as MD5 were once considered decent for non-critical uses but found vulnerable to
new attacks.
Regular audits critical as hash strengths weaken over time against evolving hardware.
Code samples:
// Salted bcrypt password hash
$hash = password_hash($password, PASSWORD_BCRYPT, [‘cost’ => 10, ‘salt’ => $salt]);